| @@ 586-600 (lines=15) @@ | ||
| 583 | * |
|
| 584 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
| 585 | */ |
|
| 586 | public function appendToEachKey($prefix) |
|
| 587 | { |
|
| 588 | $result = []; |
|
| 589 | foreach ($this->array as $key => $item) { |
|
| 590 | if ($item instanceof self) { |
|
| 591 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 592 | } elseif (\is_array($item)) { |
|
| 593 | $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
| 594 | } else { |
|
| 595 | $result[$prefix . $key] = $item; |
|
| 596 | } |
|
| 597 | } |
|
| 598 | ||
| 599 | return self::create($result); |
|
| 600 | } |
|
| 601 | ||
| 602 | /** |
|
| 603 | * Add a prefix to each value. |
|
| @@ 2767-2782 (lines=16) @@ | ||
| 2764 | * |
|
| 2765 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
| 2766 | */ |
|
| 2767 | public function prependToEachKey($suffix) |
|
| 2768 | { |
|
| 2769 | $result = []; |
|
| 2770 | foreach ($this->array as $key => $item) { |
|
| 2771 | if ($item instanceof self) { |
|
| 2772 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 2773 | } elseif (\is_array($item)) { |
|
| 2774 | $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray(); |
|
| 2775 | } else { |
|
| 2776 | $result[$key . $suffix] = $item; |
|
| 2777 | } |
|
| 2778 | ||
| 2779 | } |
|
| 2780 | ||
| 2781 | return self::create($result); |
|
| 2782 | } |
|
| 2783 | ||
| 2784 | /** |
|
| 2785 | * Add a suffix to each value. |
|