Jgleeson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387300 )

Change subject: added some minor updates around namespace container getters and 
setters
......................................................................

added some minor updates around namespace container getters and setters

Change-Id: I7ce8764e9b5f90de0431a10dcc60418b0a50ac20
---
M sites/all/modules/metrics_reporting/Statistics/Collector.php
1 file changed, 48 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/00/387300/1

diff --git a/sites/all/modules/metrics_reporting/Statistics/Collector.php 
b/sites/all/modules/metrics_reporting/Statistics/Collector.php
index a69e377..6bcdeb0 100644
--- a/sites/all/modules/metrics_reporting/Statistics/Collector.php
+++ b/sites/all/modules/metrics_reporting/Statistics/Collector.php
@@ -23,7 +23,23 @@
  */
 class Collector
 {
-    private static $instances = array();
+    /**
+     * Singleton Instance container
+     * @var array
+     */
+    private static $instances = [];
+
+    /**
+     *
+     * @var array
+     */
+    private $stats = [];
+
+    /**
+     * namespace separator
+     * @var string
+     */
+    private $separator = '.';
 
     private function __construct()
     {
@@ -34,7 +50,7 @@
      * for Statistics reporting e.g. a fixed root $componentNS of "queue." in 
QueueStatsCollector
      * so late static binding support has been added to the singleton 
implementation
      *
-     * @return Statistics
+     * @return Collector
      */
     public static function getInstance()
     {
@@ -45,7 +61,7 @@
         return self::$instances[$class];
     }
 
-    /**
+    /**I am
      * Record a statistic for a component
      *
      * TODO:
@@ -57,7 +73,7 @@
      */
     public function addStat($componentNS, $value, $type)
     {
-
+        $this->addValueToNamespace($componentNS, $value);
     }
 
     /**
@@ -142,4 +158,32 @@
 
     }
 
+    private function addValueToNamespace($namespace, $value)
+    {
+        $keys = explode($this->separator, $namespace);
+        foreach ($keys as $key) {
+            $container = &$this->stats[$key];
+        }
+        $container = $value;
+        return true;
+    }
+
+    private function removeValueFromNamespace($namespace)
+    {
+        $keys = explode($this->separator, $namespace);
+        foreach ($keys as $key) {
+            $container = &$this->stats[$key];
+        }
+        unset($container);
+    }
+
+    private function getValueFromNamespace($namespace)
+    {
+        $keys = explode($this->separator, $namespace);
+        foreach ($keys as $key) {
+            $container = &$this->stats[$key];
+        }
+        return $container;
+    }
+
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/387300
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7ce8764e9b5f90de0431a10dcc60418b0a50ac20
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Jgleeson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to