1 | <?php |
||
33 | class Config extends AbstractConfig |
||
34 | { |
||
35 | |||
36 | /** |
||
37 | * The schema of the Config file. |
||
38 | * |
||
39 | * @var Schema |
||
40 | */ |
||
41 | protected $schema; |
||
42 | |||
43 | /** |
||
44 | * The Validator class that gets asked to do the validation of the config. |
||
45 | * |
||
46 | * @since 0.1.0 |
||
47 | * |
||
48 | * @var Validator |
||
49 | */ |
||
50 | protected $validator; |
||
51 | |||
52 | /** |
||
53 | * Instantiate the Config object. |
||
54 | * |
||
55 | * It accepts either an array with the configuration settings, or a |
||
56 | * filename pointing to a PHP file it can include. |
||
57 | * |
||
58 | * @since 0.1.0 |
||
59 | * @since 0.1.6 Accepts a delimiter to parse configuration keys. |
||
60 | * |
||
61 | * @param array|string $config Array with settings or filename for the |
||
62 | * settings file. |
||
63 | * @param Schema|null $schema Optional. Config that contains default |
||
64 | * values that can get overwritten. |
||
65 | * @param Validator|null $validator Optional. Validator class that does the |
||
66 | * actual validation. |
||
67 | * @param string[]|string|null $delimiter A string or array of strings that are used as delimiters to parse |
||
68 | * configuration keys. Defaults to "\", "/" & ".". |
||
69 | * |
||
70 | * @throws InvalidConfigurationSourceException If the config source is not a string or array. |
||
71 | * @throws FailedToInstantiateParentException If the parent class could not be instantiated. |
||
72 | * @throws FailedToLoadConfigException If loading of the config source failed. |
||
73 | * @throws FailedToResolveConfigException If the config file could not be resolved. |
||
74 | * @throws InvalidConfigException If the config file is not valid. |
||
75 | */ |
||
76 | 9 | public function __construct( |
|
125 | |||
126 | /** |
||
127 | * Validate the Config file. |
||
128 | * |
||
129 | * @since 0.1.0 |
||
130 | * |
||
131 | * @return boolean |
||
132 | */ |
||
133 | 2 | public function isValid() |
|
141 | |||
142 | /** |
||
143 | * Process the passed-in defaults and merge them with the new values, while |
||
144 | * checking that all required options are set. |
||
145 | * |
||
146 | * @since 0.1.0 |
||
147 | * |
||
148 | * @param array $config Configuration settings to resolve. |
||
149 | * |
||
150 | * @return array Resolved configuration settings. |
||
151 | * @throws FailedToResolveConfigException If there are errors while resolving the options. |
||
152 | */ |
||
153 | 4 | protected function resolveOptions($config) |
|
175 | |||
176 | /** |
||
177 | * Configure the possible and required options for the Config. |
||
178 | * |
||
179 | * This should return a bool to let the resolve_options() know whether the |
||
180 | * actual resolving needs to be done or not. |
||
181 | * |
||
182 | * @since 0.1.0 |
||
183 | * |
||
184 | * @param OptionsResolver $resolver Reference to the OptionsResolver |
||
185 | * instance. |
||
186 | * |
||
187 | * @return bool Whether to do the resolving. |
||
188 | * @throws FailedToResolveConfigException If there are errors while processing. |
||
189 | */ |
||
190 | 2 | protected function configureOptions(OptionsResolver $resolver) |
|
221 | } |
||
222 |