1 | <?php |
||
12 | class Config |
||
13 | { |
||
14 | protected $registry = array(); |
||
15 | protected $loaders = array(); |
||
16 | |||
17 | /** |
||
18 | * Creates a Config instance. |
||
19 | * |
||
20 | * @param array|LoaderInterface|null $loaders array of LoaderInterface |
||
21 | */ |
||
22 | public function __construct($loaders = null) |
||
34 | |||
35 | public function addLoader(LoaderInterface $loader) |
||
39 | |||
40 | /** |
||
41 | * Returns loaded config option. If the key is not found it checks if registered loaders can |
||
42 | * find the key. |
||
43 | * |
||
44 | * @param string $key |
||
45 | * @param mixed $default - the value to be returned if the $key is not found |
||
46 | * |
||
47 | * @return mixed |
||
48 | */ |
||
49 | public function get($key, $default = null) |
||
65 | |||
66 | /** |
||
67 | * Registers a config variable |
||
68 | * |
||
69 | * @param string $key |
||
70 | * @param mixed $value |
||
71 | * |
||
72 | * @return void |
||
73 | */ |
||
74 | public function set($key, $value) |
||
98 | |||
99 | /** |
||
100 | * Tries to find needed resource by looping each of registered loaders. |
||
101 | * |
||
102 | * @param string $resource |
||
103 | * |
||
104 | * @return array|null Returns null if resource is not found |
||
105 | */ |
||
106 | protected function discover($resource) |
||
115 | |||
116 | /** |
||
117 | * Search for a key with dot notation in the array. If the key is not found NULL is returned |
||
118 | * |
||
119 | * @param string $key |
||
120 | * |
||
121 | * @return mixed|null Returns NULL if the key is not found. |
||
122 | */ |
||
123 | protected function parse($key) |
||
139 | } |
||
140 |