aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2010-09-16 16:29:10 -0300
committerSilvio <s1lv10@uol.com.br>2010-09-16 16:29:10 -0300
commit1a75499bf5a0d42f6f866ae59f4a8ae17a15f175 (patch)
tree60462d00531091144551ea796f9ddccb15c05074 /lib
parent63d9e8c6458d337e8f15db8e51fb0e54c6333d45 (diff)
downloadsf_isis_importer_plugin-1a75499bf5a0d42f6f866ae59f4a8ae17a15f175.tar.gz
sf_isis_importer_plugin-1a75499bf5a0d42f6f866ae59f4a8ae17a15f175.tar.bz2
sfIsisImporterStats now relying in a doctine model
Diffstat (limited to 'lib')
-rw-r--r--lib/sfIsisImporterStats.class.php52
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()
- {
- }
}