1 | <?php |
||
9 | class Config implements ConfigInterface, ConfigInterpolatorInterface |
||
10 | { |
||
11 | use ConfigInterpolatorTrait; |
||
12 | |||
13 | /** |
||
14 | * @var Data |
||
15 | */ |
||
16 | protected $config; |
||
17 | |||
18 | /** |
||
19 | * TODO: make this private in 2.0 to prevent being saved as an array |
||
20 | * Making private now breaks backward compatibility |
||
21 | * |
||
22 | * @var Data |
||
23 | */ |
||
24 | protected $defaults; |
||
25 | |||
26 | /** |
||
27 | * Create a new configuration object, and initialize it with |
||
28 | * the provided nested array containing configuration data. |
||
29 | * |
||
30 | * @param array $data - Config data to store |
||
31 | */ |
||
32 | public function __construct(array $data = null) |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function has($key) |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function get($key, $defaultFallback = null) |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function set($key, $value) |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function import($data) |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | public function replace($data) |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function combine($data) |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function export() |
||
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | public function hasDefault($key) |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | public function getDefault($key, $defaultFallback = null) |
||
117 | |||
118 | /** |
||
119 | * {@inheritdoc} |
||
120 | */ |
||
121 | public function setDefault($key, $value) |
||
126 | |||
127 | /** |
||
128 | * Return the class $defaults property and ensure it's a Data object |
||
129 | * TODO: remove Data object validation in 2.0 |
||
130 | * |
||
131 | * @return Data |
||
132 | */ |
||
133 | protected function getDefaults() |
||
141 | |||
142 | /** |
||
143 | * Sets the $defaults class parameter |
||
144 | * TODO: remove support for array in 2.0 as this would currently break backward compatibility |
||
145 | * |
||
146 | * @param Data|array $defaults |
||
147 | * |
||
148 | * @throws \Exception |
||
149 | */ |
||
150 | protected function setDefaults($defaults) |
||
160 | } |
||
161 |