1 | <?php |
||
9 | class Manager implements ArrayAccess, ManagerContract |
||
10 | { |
||
11 | /** |
||
12 | * All of the configuration items. |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $items = []; |
||
17 | |||
18 | /** |
||
19 | * Construct a new Config Manager pre-loaded with items. |
||
20 | * |
||
21 | * @param array $items |
||
22 | * |
||
23 | * @author Glenn McEwan <[email protected]> |
||
24 | */ |
||
25 | 16 | public function __construct(array $items = []) |
|
29 | |||
30 | /** |
||
31 | * Check if a key exists in the config. |
||
32 | * |
||
33 | * @param string $key The key in the config to check for existence |
||
34 | * |
||
35 | * @return bool |
||
36 | * |
||
37 | * @author Glenn McEwan <[email protected]> |
||
38 | */ |
||
39 | 6 | public function has($key) |
|
57 | |||
58 | /** |
||
59 | * Retrieve a given config value by its key. |
||
60 | * |
||
61 | * @param string $key Config key |
||
62 | * @param mixed $default Default value if the key doesn't exist |
||
63 | * |
||
64 | * @return mixed The config value |
||
65 | * |
||
66 | * @author Glenn McEwan <[email protected]> |
||
67 | */ |
||
68 | 13 | public function get($key, $default = null) |
|
86 | |||
87 | /** |
||
88 | * Retrieve all of the config items. |
||
89 | * |
||
90 | * @return array |
||
91 | * |
||
92 | * @author Glenn McEwan <[email protected]> |
||
93 | */ |
||
94 | 16 | public function all() |
|
98 | |||
99 | /** |
||
100 | * Set a config entry by key, optional value. |
||
101 | * |
||
102 | * @param string $key Config key |
||
103 | * @param mixed $value Config value |
||
104 | * |
||
105 | * @return static return self / $this for chain-ability |
||
106 | * |
||
107 | * @author Glenn McEwan <[email protected]> |
||
108 | */ |
||
109 | 7 | public function set($key, $value = null) |
|
127 | |||
128 | /** |
||
129 | * If a parent key is passed, for example, as 'deployment', |
||
130 | * then the data will be put in to the Config as deployment.*, |
||
131 | * otherwise it will be placed at the root level in the config. |
||
132 | * |
||
133 | * Optionally, a parent key in which the config data will reside. |
||
134 | * |
||
135 | * @param mixed $value The array to set in to the config |
||
136 | * @param string $key [optional] A parent config key to set the array in to |
||
137 | * |
||
138 | * @author Glenn McEwan <[email protected]> |
||
139 | */ |
||
140 | 2 | public function setArray($value, $key = null) |
|
152 | |||
153 | /* |
||
154 | |-------------------------------------------------------------------------- |
||
155 | | Interface - ArrayAccess |
||
156 | |-------------------------------------------------------------------------- |
||
157 | | |
||
158 | */ |
||
159 | |||
160 | /** |
||
161 | * Check if a key exists in the config. |
||
162 | * |
||
163 | * @param string $key The key in the config to check for existence |
||
164 | * |
||
165 | * @return bool |
||
166 | * |
||
167 | * @author Glenn McEwan <[email protected]> |
||
168 | */ |
||
169 | 1 | public function offsetExists($key) |
|
173 | |||
174 | /** |
||
175 | * Retrieve a given config value by its key. |
||
176 | * |
||
177 | * @param string $key Config key |
||
178 | * |
||
179 | * @return mixed The config value |
||
180 | * |
||
181 | * @author Glenn McEwan <[email protected]> |
||
182 | */ |
||
183 | 3 | public function offsetGet($key) |
|
187 | |||
188 | /** |
||
189 | * Set a config entry by key, optional value. |
||
190 | * |
||
191 | * @param string $key Config key |
||
192 | * @param mixed $value Config value |
||
193 | * |
||
194 | * @author Glenn McEwan <[email protected]> |
||
195 | */ |
||
196 | 1 | public function offsetSet($key, $value) |
|
200 | |||
201 | /** |
||
202 | * Unset a configuration option. |
||
203 | * |
||
204 | * @param string $key |
||
205 | * |
||
206 | * @author Glenn McEwan <[email protected]> |
||
207 | */ |
||
208 | 1 | public function offsetUnset($key) |
|
212 | } |
||
213 |