summaryrefslogtreecommitdiff
path: root/src/Config/Config.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-11-28 15:43:51 +0100
committerGitHub <noreply@github.com>2017-11-28 15:43:51 +0100
commit599f2fd264bfc7b1b6826fe206442806e317340f (patch)
tree50cf84d7d07d11bd65b45c2c17f37632f6cd8eff /src/Config/Config.php
parenta5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff)
parenteda7f7788ea8012bd8be46405c56a666c11f3fa5 (diff)
Merge pull request #365 from engelsystem/feature-igel-rewrite
Feature igel rewrite
Diffstat (limited to 'src/Config/Config.php')
-rw-r--r--src/Config/Config.php100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/Config/Config.php b/src/Config/Config.php
new file mode 100644
index 00000000..34c21a78
--- /dev/null
+++ b/src/Config/Config.php
@@ -0,0 +1,100 @@
+<?php
+
+namespace Engelsystem\Config;
+
+class Config
+{
+ /**
+ * The config values
+ *
+ * @var array
+ */
+ protected $data = [];
+
+ /**
+ * @param string|null $key
+ * @param mixed $default
+ * @return mixed
+ */
+ public function get($key, $default = null)
+ {
+ if (is_null($key)) {
+ return $this->data;
+ }
+
+ if ($this->has($key)) {
+ return $this->data[$key];
+ }
+
+ return $default;
+ }
+
+ /**
+ * @param string|array $key
+ * @param mixed $value
+ */
+ public function set($key, $value = null)
+ {
+ if (is_array($key)) {
+ foreach ($key as $configKey => $configValue) {
+ $this->set($configKey, $configValue);
+ }
+
+ return;
+ }
+
+ $this->data[$key] = $value;
+ }
+
+ /**
+ * @param string $key
+ * @return bool
+ */
+ public function has($key)
+ {
+ return isset($this->data[$key]);
+ }
+
+ /**
+ * @param string $key
+ */
+ public function remove($key)
+ {
+ unset($this->data[$key]);
+ }
+
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function __get($key)
+ {
+ return $this->get($key);
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ */
+ public function __set($key, $value)
+ {
+ $this->set($key, $value);
+ }
+
+ /**
+ * @param string $key
+ * @return bool
+ */
+ public function __isset($key)
+ {
+ return $this->has($key);
+ }
+
+ /**
+ * @param string $key
+ */
+ public function __unset($key)
+ {
+ $this->remove($key);
+ }
+}