1 | <?php |
||
19 | class Config implements Repository |
||
20 | { |
||
21 | use StorageConverterTrait; |
||
22 | /** |
||
23 | * @var string The delimiter used in the array keys to specify the heirachy |
||
24 | */ |
||
25 | const KEY_DELIMITER = '.'; |
||
26 | |||
27 | /** |
||
28 | * @var string the pattern to match array keys |
||
29 | */ |
||
30 | const ARRAY_PATTERN = "/\[([0-9]+)\]$/"; |
||
31 | |||
32 | /** |
||
33 | * The configuration data |
||
34 | * @var array |
||
35 | */ |
||
36 | private $data; |
||
37 | |||
38 | public $modifiers; |
||
39 | |||
40 | /** |
||
41 | * @var \Illuminate\Support\Arr |
||
42 | */ |
||
43 | private $arrHelper; |
||
44 | |||
45 | private $storage; |
||
46 | |||
47 | /** |
||
48 | * constructor |
||
49 | * The initial data |
||
50 | * |
||
51 | * @param array|StorageInterface $data the flattened data |
||
52 | * @param Arr|null $arrHelper the array helper |
||
53 | */ |
||
54 | public function __construct($data = [], Arr $arrHelper = null) |
||
73 | |||
74 | /** |
||
75 | * Set the array helper |
||
76 | * |
||
77 | * @param Arr|null $arrHelper |
||
78 | */ |
||
79 | private function setArrHelper(Arr $arrHelper = null) |
||
86 | |||
87 | /** |
||
88 | * Reduce the configuration to a simple key/value array, despite the |
||
89 | * heirachy of information |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | public function flatten() |
||
97 | |||
98 | /** |
||
99 | * Create/Update a configuration value |
||
100 | * |
||
101 | * @param string $key |
||
102 | * @param mixed $value |
||
103 | */ |
||
104 | public function set($key, $value = null) |
||
121 | |||
122 | /** |
||
123 | * Get the configuration value based on it's key |
||
124 | * |
||
125 | * @param string $key |
||
126 | * @param mixed $default |
||
127 | * @return mixed |
||
128 | */ |
||
129 | public function get($key, $default = null) |
||
136 | |||
137 | /*** |
||
138 | * Get all of the configuration data in it's hierarchical state |
||
139 | */ |
||
140 | public function all() |
||
144 | |||
145 | /** |
||
146 | * Remove an item from the configuration |
||
147 | * |
||
148 | * @param string $key |
||
149 | * @return boolean |
||
150 | */ |
||
151 | public function forget($key) |
||
159 | |||
160 | /** |
||
161 | * Clear all of the settings from the configuration |
||
162 | * |
||
163 | * @return boolean |
||
164 | */ |
||
165 | public function clear() |
||
174 | |||
175 | /** |
||
176 | * Check if a configuration setting exists |
||
177 | * |
||
178 | * @param string $key |
||
179 | * @return boolean |
||
180 | */ |
||
181 | public function has($key) |
||
185 | |||
186 | /** |
||
187 | * Prepend a value onto the key. |
||
188 | * |
||
189 | * If that existing key is not an array it will be converted into an array |
||
190 | * and the the value will be the first element of the array |
||
191 | * |
||
192 | * @param string $key |
||
193 | * @param mixed $value |
||
194 | * @return void |
||
195 | */ |
||
196 | public function prepend($key, $value) |
||
202 | |||
203 | /** |
||
204 | * Push a value onto the key |
||
205 | * |
||
206 | * If that existing key is not an array it will be converted into an array |
||
207 | * and the the value will be the first element of the array |
||
208 | * |
||
209 | * @param string $key |
||
210 | * @param mixed $value |
||
211 | * @return void |
||
212 | */ |
||
213 | public function push($key, $value) |
||
219 | |||
220 | /** |
||
221 | * Get the value, as an array |
||
222 | * |
||
223 | * @param string $key |
||
224 | * @return array any existing value will be converted to the first element |
||
225 | * of the array |
||
226 | */ |
||
227 | private function getAsArray($key) |
||
235 | |||
236 | |||
237 | /** |
||
238 | * Validate the value as safe for this object |
||
239 | * |
||
240 | * @param mixed $value the value to test |
||
241 | * @return boolean |
||
242 | */ |
||
243 | private function isValidValue($value) |
||
253 | } |
||
254 |