| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCommunity\Framework\Foundation; |
| 4 |
|
| 5 |
use FluentCommunity\Framework\Support\Arr; |
| 6 |
|
| 7 |
class Config |
| 8 |
{ |
| 9 |
/** |
| 10 |
* The config data |
| 11 |
* @var array |
| 12 |
*/ |
| 13 |
protected $data = []; |
| 14 |
|
| 15 |
/** |
| 16 |
* Construct the Config instance |
| 17 |
* @param null |
| 18 |
*/ |
| 19 |
public function __construct($data) |
| 20 |
{ |
| 21 |
$this->data = $data; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Retrieve all config data |
| 26 |
* @return array |
| 27 |
*/ |
| 28 |
public function all() |
| 29 |
{ |
| 30 |
return $this->get(); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Retrieve specific item from config array |
| 35 |
* @param string $key |
| 36 |
* @param string $default |
| 37 |
* @return mixed |
| 38 |
*/ |
| 39 |
public function get($key = null, $default = null) |
| 40 |
{ |
| 41 |
return $key ? Arr::get($this->data, $key, $default) : $this->data; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Set an item into the config array on the fly. |
| 46 |
* @param string $key |
| 47 |
* @param mkixed $value |
| 48 |
*/ |
| 49 |
public function set($key, $value) |
| 50 |
{ |
| 51 |
Arr::set($this->data, $key, $value); |
| 52 |
} |
| 53 |
} |
| 54 |
|