1 | <?php |
||
11 | class Repository extends NamespacedItemResolver implements \ArrayAccess, ConfigContract |
||
12 | { |
||
13 | /** |
||
14 | * The loader implementation. |
||
15 | * |
||
16 | * @var \Magister\Services\Config\LoaderInterface |
||
17 | */ |
||
18 | protected $loader; |
||
19 | |||
20 | /** |
||
21 | * All of the configuration items. |
||
22 | * |
||
23 | * @var array |
||
24 | */ |
||
25 | protected $items = []; |
||
26 | |||
27 | /** |
||
28 | * Create a new configuration repository. |
||
29 | * |
||
30 | * @param \Magister\Services\Config\LoaderInterface $loader |
||
31 | */ |
||
32 | public function __construct(LoaderInterface $loader) |
||
36 | |||
37 | /** |
||
38 | * Determine if the given configuration value exists. |
||
39 | * |
||
40 | * @param string $key |
||
41 | * |
||
42 | * @return bool |
||
43 | */ |
||
44 | public function has($key) |
||
48 | |||
49 | /** |
||
50 | * Set a given configuration value. |
||
51 | * |
||
52 | * @param string $key |
||
53 | * @param mixed $value |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | public function set($key, $value) |
||
71 | |||
72 | /** |
||
73 | * Get the specified configuration value. |
||
74 | * |
||
75 | * @param string $key |
||
76 | * @param array $replace |
||
77 | * @param mixed $default |
||
78 | * |
||
79 | * @return mixed |
||
80 | */ |
||
81 | public function get($key, array $replace = [], $default = null) |
||
99 | |||
100 | /** |
||
101 | * Replace all occurrences of a string in a group. |
||
102 | * |
||
103 | * @param string $key |
||
104 | * @param string $search |
||
105 | * @param mixed $replace |
||
106 | * |
||
107 | * @return void |
||
108 | */ |
||
109 | public function replace($key, $search, $replace) |
||
125 | |||
126 | /** |
||
127 | * Load the configuration group for the key. |
||
128 | * |
||
129 | * @param string $group |
||
130 | * @param string $namespace |
||
131 | * @param string $collection |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | protected function load($group, $namespace, $collection) |
||
145 | |||
146 | /** |
||
147 | * Retrieve a language line out the loaded array. |
||
148 | * |
||
149 | * @param string $collection |
||
150 | * @param string $item |
||
151 | * @param array $replace |
||
152 | * @param mixed $default |
||
153 | * |
||
154 | * @return string|null |
||
155 | */ |
||
156 | protected function getLine($collection, $item, array $replace, $default = null) |
||
166 | |||
167 | /** |
||
168 | * Make the place-holder replacements on a line. |
||
169 | * |
||
170 | * @param string $line |
||
171 | * @param array $replace |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | protected function makeReplacements($line, array $replace) |
||
183 | |||
184 | /** |
||
185 | * Get the collection identifier. |
||
186 | * |
||
187 | * @param string $group |
||
188 | * @param string $namespace |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | protected function getCollection($group, $namespace = null) |
||
198 | |||
199 | /** |
||
200 | * Get the loader implementation. |
||
201 | * |
||
202 | * @return \Magister\Services\Config\LoaderInterface |
||
203 | */ |
||
204 | public function getLoader() |
||
208 | |||
209 | /** |
||
210 | * Set the loader implementation. |
||
211 | * |
||
212 | * @param \Magister\Services\Config\LoaderInterface $loader |
||
213 | * |
||
214 | * @return void |
||
215 | */ |
||
216 | public function setLoader(LoaderInterface $loader) |
||
220 | |||
221 | /** |
||
222 | * Get all of the configuration items for the application. |
||
223 | * |
||
224 | * @return array |
||
225 | */ |
||
226 | public function all() |
||
230 | |||
231 | /** |
||
232 | * Set a configuration option. |
||
233 | * |
||
234 | * @param string $key |
||
235 | * @param mixed $value |
||
236 | * |
||
237 | * @return void |
||
238 | */ |
||
239 | public function offsetSet($key, $value) |
||
243 | |||
244 | /** |
||
245 | * Get a configuration option. |
||
246 | * |
||
247 | * @param string $key |
||
248 | * |
||
249 | * @return mixed |
||
250 | */ |
||
251 | public function offsetGet($key) |
||
255 | |||
256 | /** |
||
257 | * Determine if the given configuration option exists. |
||
258 | * |
||
259 | * @param string $key |
||
260 | * |
||
261 | * @return bool |
||
262 | */ |
||
263 | public function offsetExists($key) |
||
267 | |||
268 | /** |
||
269 | * Unset a configuration option. |
||
270 | * |
||
271 | * @param string $key |
||
272 | * |
||
273 | * @return void |
||
274 | */ |
||
275 | public function offsetUnset($key) |
||
279 | } |
||
280 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.