@@ 600-618 (lines=19) @@ | ||
597 | * |
|
598 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
599 | */ |
|
600 | public function appendToEachKey($prefix) |
|
601 | { |
|
602 | // init |
|
603 | $result = []; |
|
604 | ||
605 | foreach ($this->getGenerator() as $key => $item) { |
|
606 | if ($item instanceof self) { |
|
607 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
608 | } elseif (\is_array($item)) { |
|
609 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
610 | ->appendToEachKey($prefix) |
|
611 | ->toArray(); |
|
612 | } else { |
|
613 | $result[$prefix . $key] = $item; |
|
614 | } |
|
615 | } |
|
616 | ||
617 | return self::create($result, $this->iteratorClass, false); |
|
618 | } |
|
619 | ||
620 | /** |
|
621 | * Add a prefix to each value. |
|
@@ 2889-2906 (lines=18) @@ | ||
2886 | * |
|
2887 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
2888 | */ |
|
2889 | public function prependToEachKey($suffix) |
|
2890 | { |
|
2891 | // init |
|
2892 | $result = []; |
|
2893 | ||
2894 | foreach ($this->getGenerator() as $key => $item) { |
|
2895 | if ($item instanceof self) { |
|
2896 | $result[$key] = $item->prependToEachKey($suffix); |
|
2897 | } elseif (\is_array($item)) { |
|
2898 | $result[$key] = self::create($item, $this->iteratorClass, false)->prependToEachKey($suffix)->toArray(); |
|
2899 | } else { |
|
2900 | $result[$key . $suffix] = $item; |
|
2901 | } |
|
2902 | ||
2903 | } |
|
2904 | ||
2905 | return self::create($result, $this->iteratorClass, false); |
|
2906 | } |
|
2907 | ||
2908 | /** |
|
2909 | * Add a suffix to each value. |