aboutsummaryrefslogtreecommitdiff
path: root/lib/sfIsisImporterStats.class.php
blob: d7dae34d30d4a599afc45c6cb3d8beeda13b6430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php

/**
 * Statistics gathering for importing procedures.
 */
class sfIsisImporterStats
{
  /**
   * @var $instance Singleton instance
   */
  private static $instance = null;

  /**
   * Get the singleton instance.
   */
  public static function getInstance()
  {
    if(self::$instance == null) {
      self::$instance = new self;
    }

    return self::$instance;
  }

  /**
   * Constructor.
   */ 
  private function __construct()
  {
    $this->stats = array();
  }  

  /**
   * Simple accumulator.
   *
   * @param string $section Section name
   */
  public function increase($section)
  {
    $this->stats[$section]++;
  }

  /**
   * Compute soundex.
   *
   * @param string $name Name
   */
  public function soundex($name) {
    $this->stats['sounded'][soundex($name)] = $name;
  }

  /**
   * Compute metaphone.
   *
   * @param string $name Name
   */
  public function metaphone($name) {
    $this->stats['sounded'][metaphone($name)] = $name;
  }

  /**
   * Compute similar words indexes.
   *
   * @param string $name Name
   */
  public function similar($name) {
    $this->soundex($name);
    $this->metaphone($name);
  }

  /**
   * Display statistics.
   *
   * @todo Write and test
   */
  public function display() {
  }
}