2017-01-21 23:07:20 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Config;
|
|
|
|
|
2018-01-14 01:45:23 +01:00
|
|
|
use Illuminate\Support\Fluent;
|
|
|
|
|
|
|
|
class Config extends Fluent
|
2017-01-21 23:07:20 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The config values
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2018-01-14 01:45:23 +01:00
|
|
|
protected $attributes = [];
|
2017-01-21 23:07:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $key
|
|
|
|
* @param mixed $default
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function get($key, $default = null)
|
|
|
|
{
|
|
|
|
if (is_null($key)) {
|
2018-01-14 01:45:23 +01:00
|
|
|
return $this->attributes;
|
2017-01-21 23:07:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->has($key)) {
|
2018-01-14 01:45:23 +01:00
|
|
|
return $this->attributes[$key];
|
2017-01-21 23:07:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-14 01:45:23 +01:00
|
|
|
$this->attributes[$key] = $value;
|
2017-01-21 23:07:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $key
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function has($key)
|
|
|
|
{
|
2018-01-14 01:45:23 +01:00
|
|
|
return $this->offsetExists($key);
|
2017-01-21 23:07:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $key
|
|
|
|
*/
|
|
|
|
public function remove($key)
|
|
|
|
{
|
2018-01-14 01:45:23 +01:00
|
|
|
$this->offsetUnset($key);
|
2017-01-21 23:07:20 +01:00
|
|
|
}
|
|
|
|
}
|