Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Becker <fabian.becker@uni-tuebingen.de>2013-09-29 19:15:14 +0400
committerFabian Becker <fabian.becker@uni-tuebingen.de>2013-09-29 19:15:14 +0400
commit05f76a5826e710929ebc558e846847056222e4fb (patch)
tree297f2266c8f09bf91089a95907315bdce0c5e1b3 /core/Registry.php
parentcbedab1a2c2a47afbbcdd2909d2036ff2f2b62c1 (diff)
Add implementation of simple Registry (removing Zend_* dependency)
Diffstat (limited to 'core/Registry.php')
-rw-r--r--core/Registry.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/core/Registry.php b/core/Registry.php
new file mode 100644
index 0000000000..e2fa0278cb
--- /dev/null
+++ b/core/Registry.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+namespace Piwik;
+
+/**
+ * Registry class.
+ *
+ * @package Piwik
+ */
+class Registry
+{
+ private static $instance;
+ private $data;
+
+ private function __construct() {
+ $this->data = array();
+ }
+
+ public static function getInstance() {
+ if(self::$instance == null) {
+ self::$instance = new Registry();
+ }
+ return self::$instance;
+ }
+
+ public static function isRegistered($key) {
+ return self::getInstance()->hasKey($key);
+ }
+
+ public static function get($key) {
+ return self::getInstance()->getKey($key);
+ }
+
+ public static function set($key, $value) {
+ self::getInstance()->setKey($key, $value);
+ }
+
+ public static function unsetInstance() {
+ self::$instance = null;
+ }
+
+ public function setKey($key, $value) {
+ $this->data[$key] = $value;
+ }
+
+ public function getKey($key) {
+ if(!$this->hasKey($key)) {
+ return null;
+ }
+ return $this->data[$key];
+ }
+
+ public function hasKey($key) {
+ return array_key_exists($key, $this->data);
+ }
+}