| @@ 554-568 (lines=15) @@ | ||
| 551 | * |
|
| 552 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
| 553 | */ |
|
| 554 | public function appendToEachKey($prefix) |
|
| 555 | { |
|
| 556 | $result = []; |
|
| 557 | foreach ($this->array as $key => $item) { |
|
| 558 | if ($item instanceof self) { |
|
| 559 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 560 | } elseif (\is_array($item)) { |
|
| 561 | $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
| 562 | } else { |
|
| 563 | $result[$prefix . $key] = $item; |
|
| 564 | } |
|
| 565 | } |
|
| 566 | ||
| 567 | return self::create($result); |
|
| 568 | } |
|
| 569 | ||
| 570 | /** |
|
| 571 | * Add a prefix to each value. |
|
| @@ 2699-2714 (lines=16) @@ | ||
| 2696 | * |
|
| 2697 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
| 2698 | */ |
|
| 2699 | public function prependToEachKey($suffix) |
|
| 2700 | { |
|
| 2701 | $result = []; |
|
| 2702 | foreach ($this->array as $key => $item) { |
|
| 2703 | if ($item instanceof self) { |
|
| 2704 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 2705 | } elseif (\is_array($item)) { |
|
| 2706 | $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray(); |
|
| 2707 | } else { |
|
| 2708 | $result[$key . $suffix] = $item; |
|
| 2709 | } |
|
| 2710 | ||
| 2711 | } |
|
| 2712 | ||
| 2713 | return self::create($result); |
|
| 2714 | } |
|
| 2715 | ||
| 2716 | /** |
|
| 2717 | * Add a suffix to each value. |
|