| @@ 98-114 (lines=17) @@ | ||
| 95 | * @param mixed $value |
|
| 96 | * @return void |
|
| 97 | */ |
|
| 98 | public function push(string $path, $value) |
|
| 99 | { |
|
| 100 | $keys = explode('.', $path); |
|
| 101 | $array = &$this->items; |
|
| 102 | ||
| 103 | while (count($keys) > 0) { |
|
| 104 | $activeKey = array_shift($keys); |
|
| 105 | ||
| 106 | if (!isset($array[$activeKey]) || !is_array($array[$activeKey])) { |
|
| 107 | $array[$activeKey] = [$array[$activeKey]]; |
|
| 108 | } |
|
| 109 | ||
| 110 | $array = &$array[$activeKey]; |
|
| 111 | } |
|
| 112 | ||
| 113 | array_push($array, $value); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Sets value to the configuration data. |
|
| @@ 123-139 (lines=17) @@ | ||
| 120 | * @param $value |
|
| 121 | * @return void |
|
| 122 | */ |
|
| 123 | public function set(string $path, $value) |
|
| 124 | { |
|
| 125 | $keys = explode('.', $path); |
|
| 126 | $array = &$this->items; |
|
| 127 | ||
| 128 | while (count($keys) > 1) { |
|
| 129 | $activeKey = array_shift($keys); |
|
| 130 | ||
| 131 | if (!isset($array[$activeKey]) || !is_array($array[$activeKey])) { |
|
| 132 | $array[$activeKey] = []; |
|
| 133 | } |
|
| 134 | ||
| 135 | $array = &$array[$activeKey]; |
|
| 136 | } |
|
| 137 | ||
| 138 | $array[array_shift($keys)] = $value; |
|
| 139 | } |
|
| 140 | } |
|
| 141 | ||