summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-01-14 01:45:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2018-01-14 01:45:23 +0100
commite0b58d2a7d5aac5019a666ea79d3910448ba9c56 (patch)
treec4f439ab99ec8d6f537286feaa0118ca6af86840
parentddadaada9dc1bd288c82da840a4c4f02767d3e43 (diff)
Added illuminate/support and Fluent Interface to Config
-rw-r--r--composer.json1
-rw-r--r--src/Config/Config.php51
-rw-r--r--src/helpers.php15
3 files changed, 10 insertions, 57 deletions
diff --git a/composer.json b/composer.json
index ed34ba03..83b623da 100644
--- a/composer.json
+++ b/composer.json
@@ -17,6 +17,7 @@
"php": ">=7.0.0",
"erusev/parsedown": "^1.6",
"illuminate/container": "5.5.*",
+ "illuminate/support": "^5.5",
"psr/container": "^1.0",
"psr/log": "^1.0",
"symfony/http-foundation": "^3.3",
diff --git a/src/Config/Config.php b/src/Config/Config.php
index 34c21a78..b1a93324 100644
--- a/src/Config/Config.php
+++ b/src/Config/Config.php
@@ -2,14 +2,16 @@
namespace Engelsystem\Config;
-class Config
+use Illuminate\Support\Fluent;
+
+class Config extends Fluent
{
/**
* The config values
*
* @var array
*/
- protected $data = [];
+ protected $attributes = [];
/**
* @param string|null $key
@@ -19,11 +21,11 @@ class Config
public function get($key, $default = null)
{
if (is_null($key)) {
- return $this->data;
+ return $this->attributes;
}
if ($this->has($key)) {
- return $this->data[$key];
+ return $this->attributes[$key];
}
return $default;
@@ -43,7 +45,7 @@ class Config
return;
}
- $this->data[$key] = $value;
+ $this->attributes[$key] = $value;
}
/**
@@ -52,7 +54,7 @@ class Config
*/
public function has($key)
{
- return isset($this->data[$key]);
+ return $this->offsetExists($key);
}
/**
@@ -60,41 +62,6 @@ class Config
*/
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);
+ $this->offsetUnset($key);
}
}
diff --git a/src/helpers.php b/src/helpers.php
index 5a48498a..c3c727ec 100644
--- a/src/helpers.php
+++ b/src/helpers.php
@@ -67,21 +67,6 @@ function config_path($path = '')
/**
* @param string $key
* @param mixed $default
- * @return mixed
- */
-function env($key, $default = null)
-{
- $value = getenv($key);
- if ($value === false) {
- return $default;
- }
-
- return $value;
-}
-
-/**
- * @param string $key
- * @param mixed $default
* @return Request|mixed
*/
function request($key = null, $default = null)