1 | <?php |
||
14 | class ChapiConfig implements ChapiConfigInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var string[] |
||
18 | */ |
||
19 | private $aDirectoryPaths = []; |
||
20 | |||
21 | /** |
||
22 | * @var YamlParser |
||
23 | */ |
||
24 | private $oParser; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $sActiveProfile = ''; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $aConfig = null; |
||
35 | |||
36 | /** |
||
37 | * ChapiConfig constructor. |
||
38 | * @param array $aDirectoryPaths |
||
39 | * @param YamlParser $oParser |
||
40 | * @param string $sActiveProfile |
||
41 | */ |
||
42 | 3 | public function __construct( |
|
52 | |||
53 | /** |
||
54 | * @inheritdoc |
||
55 | */ |
||
56 | 2 | public function getProfileConfig() { |
|
60 | |||
61 | /** |
||
62 | * @inheritdoc |
||
63 | */ |
||
64 | 3 | public function getConfig() { |
|
71 | |||
72 | /** |
||
73 | * @return array |
||
74 | */ |
||
75 | 3 | private function loadConfigs() { |
|
91 | |||
92 | /** |
||
93 | * @param string $sPath |
||
94 | * @return array |
||
95 | */ |
||
96 | 3 | private function loadConfig($sPath) { |
|
109 | |||
110 | /** |
||
111 | * array_merge_recursive does indeed merge arrays, but it converts values with duplicate |
||
112 | * keys to arrays rather than overwriting the value in the first array with the duplicate |
||
113 | * value in the second array, as array_merge does. I.e., with array_merge_recursive, |
||
114 | * this happens (documented behavior): |
||
115 | * |
||
116 | * array_merge_recursive(array('key' => 'org value'), array('key' => 'new value')); |
||
117 | * => array('key' => array('org value', 'new value')); |
||
118 | * |
||
119 | * array_merge_recursive_distinct does not change the datatypes of the values in the arrays. |
||
120 | * Matching keys' values in the second array overwrite those in the first array, as is the |
||
121 | * case with array_merge, i.e.: |
||
122 | * |
||
123 | * array_merge_recursive_distinct(array('key' => 'org value'), array('key' => 'new value')); |
||
124 | * => array('key' => array('new value')); |
||
125 | * |
||
126 | * Parameters are passed by reference, though only for performance reasons. They're not |
||
127 | * altered by this function. |
||
128 | * |
||
129 | * @param array $array1 |
||
130 | * @param array $array2 |
||
131 | * @return array |
||
132 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
||
133 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
||
134 | * |
||
135 | * @see http://php.net/manual/de/function.array-merge-recursive.php |
||
136 | */ |
||
137 | 3 | private static function arrayMergeRecursiveDistinct(array &$array1, array &$array2) |
|
163 | } |