| @@ 26-42 (lines=17) @@ | ||
| 23 | /** |
|
| 24 | * @inheritdoc |
|
| 25 | */ |
|
| 26 | public function push(string $path, $value) |
|
| 27 | { |
|
| 28 | $keys = explode('.', $path); |
|
| 29 | $array = &$this->items; |
|
| 30 | ||
| 31 | while (count($keys) > 0) { |
|
| 32 | $activeKey = array_shift($keys); |
|
| 33 | ||
| 34 | if (!isset($array[$activeKey]) || !is_array($array[$activeKey])) { |
|
| 35 | $array[$activeKey] = [$array[$activeKey]]; |
|
| 36 | } |
|
| 37 | ||
| 38 | $array = &$array[$activeKey]; |
|
| 39 | } |
|
| 40 | ||
| 41 | array_push($array, $value); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @inheritdoc |
|
| @@ 47-63 (lines=17) @@ | ||
| 44 | /** |
|
| 45 | * @inheritdoc |
|
| 46 | */ |
|
| 47 | public function set(string $path, $value) |
|
| 48 | { |
|
| 49 | $keys = explode('.', $path); |
|
| 50 | $array = &$this->items; |
|
| 51 | ||
| 52 | while (count($keys) > 1) { |
|
| 53 | $activeKey = array_shift($keys); |
|
| 54 | ||
| 55 | if (!isset($array[$activeKey]) || !is_array($array[$activeKey])) { |
|
| 56 | $array[$activeKey] = []; |
|
| 57 | } |
|
| 58 | ||
| 59 | $array = &$array[$activeKey]; |
|
| 60 | } |
|
| 61 | ||
| 62 | $array[array_shift($keys)] = $value; |
|
| 63 | } |
|
| 64 | } |
|
| 65 | ||