| @@ 603-621 (lines=19) @@ | ||
| 600 | * |
|
| 601 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
| 602 | */ |
|
| 603 | public function appendToEachKey($prefix) |
|
| 604 | { |
|
| 605 | // init |
|
| 606 | $result = []; |
|
| 607 | ||
| 608 | foreach ($this->getGenerator() as $key => $item) { |
|
| 609 | if ($item instanceof self) { |
|
| 610 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 611 | } elseif (\is_array($item)) { |
|
| 612 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
| 613 | ->appendToEachKey($prefix) |
|
| 614 | ->toArray(); |
|
| 615 | } else { |
|
| 616 | $result[$prefix . $key] = $item; |
|
| 617 | } |
|
| 618 | } |
|
| 619 | ||
| 620 | return self::create($result, $this->iteratorClass, false); |
|
| 621 | } |
|
| 622 | ||
| 623 | /** |
|
| 624 | * Add a prefix to each value. |
|
| @@ 2865-2882 (lines=18) @@ | ||
| 2862 | * |
|
| 2863 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
| 2864 | */ |
|
| 2865 | public function prependToEachKey($suffix) |
|
| 2866 | { |
|
| 2867 | // init |
|
| 2868 | $result = []; |
|
| 2869 | ||
| 2870 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2871 | if ($item instanceof self) { |
|
| 2872 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 2873 | } elseif (\is_array($item)) { |
|
| 2874 | $result[$key] = self::create($item, $this->iteratorClass, false)->prependToEachKey($suffix)->toArray(); |
|
| 2875 | } else { |
|
| 2876 | $result[$key . $suffix] = $item; |
|
| 2877 | } |
|
| 2878 | ||
| 2879 | } |
|
| 2880 | ||
| 2881 | return self::create($result, $this->iteratorClass, false); |
|
| 2882 | } |
|
| 2883 | ||
| 2884 | /** |
|
| 2885 | * Add a suffix to each value. |
|