diff options
-rw-r--r-- | lib/sfIsisImporterStats.class.php | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/lib/sfIsisImporterStats.class.php b/lib/sfIsisImporterStats.class.php index db5c316..21f2757 100644 --- a/lib/sfIsisImporterStats.class.php +++ b/lib/sfIsisImporterStats.class.php @@ -23,26 +23,41 @@ class sfIsisImporterStats } /** - * Constructor. - */ - private function __construct() - { - $this->stats = array(); - } - - /** * Simple accumulator. * * @param string $section Section name */ - public function increase($section) + public function increase($data) { - if (!isset($this->stats[$section])) + $stats = Doctrine_Core::getTable('ImportStat')->findByPayload($data); + + if ($stats) { - $this->stats[$section] = 0; + $stats->count++; } + else + { + $stats = new ImportStat(); + $stats->payload = $data; + $stats->count = 1; + $stats->type = 'param'; + $stats->save(); + } + } - $this->stats[$section]++; + /** + * Compute similars. + * + * @param string $name Name + * @param string $function Function that determines similarity index + */ + public function similarity($name, $function = 'soundex') + { + $stats = new ImportStat(); + $stats->param = call_user_func($function, $name); + $stats->payload = $name; + $stats->type = $function; + $stats->save(); } /** @@ -52,7 +67,7 @@ class sfIsisImporterStats */ public function soundex($name) { - $this->stats['sounded'][soundex($name)] = $name; + $this->similarity($name); } /** @@ -62,7 +77,7 @@ class sfIsisImporterStats */ public function metaphone($name) { - $this->stats['sounded'][metaphone($name)] = $name; + $this->similarity($name, 'metaphone'); } /** @@ -75,13 +90,4 @@ class sfIsisImporterStats $this->soundex($name); $this->metaphone($name); } - - /** - * Display statistics. - * - * @todo Write and test - */ - public function display() - { - } } |