Browse code

Use reflection class for statistics name

Niklas Modess authored on 24/05/2014 13:53:57
Showing 2 changed files
... ...
@@ -21,7 +21,7 @@ class Repository
21 21
 {
22 22
     protected $path;
23 23
     protected $client;
24
-    protected $statitics = array();
24
+    protected $statistics = array();
25 25
 
26 26
     public function __construct($path, Client $client)
27 27
     {
... ...
@@ -74,17 +74,17 @@ class Repository
74 74
     /**
75 75
      * Add statistic aggregator
76 76
      *
77
-     * @param StatisticsInterface|array $statitics
77
+     * @param StatisticsInterface|array $statistics
78 78
      */
79
-    public function addStatistics ($statitics)
79
+    public function addStatistics ($statistics)
80 80
     {
81
-        if (!is_array($statitics)) {
82
-            $statitics = array($statitics);
81
+        if (!is_array($statistics)) {
82
+            $statistics = array($statistics);
83 83
         }
84 84
 
85
-        foreach ($statitics as $statistic) {
86
-            $className = get_class($statistic);
87
-            $this->statistics[strtolower($className)] = $statistic;
85
+        foreach ($statistics as $statistic) {
86
+            $reflect = new \ReflectionClass($statistic);
87
+            $this->statistics[strtolower($reflect->getShortName())] = $statistic;
88 88
         }
89 89
     }
90 90
 
... ...
@@ -491,7 +491,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
491 491
 
492 492
     public function testIsAddingSingleStatistics ()
493 493
     {
494
-        $statisticsMock = \Mockery::mock('StatiticsInterface');
494
+        $statisticsMock = \Mockery::mock('Gitter\Statistics\StatiticsInterface');
495 495
 
496 496
         $repo = $this->client->createRepository(self::$tmpdir . '/teststatsrepo');
497 497
         $repo->addStatistics($statisticsMock);