| @@ 1048-1066 (lines=19) @@ | ||
| 1045 | * @psalm-return static<TKey,T> |
|
| 1046 | * @psalm-mutation-free |
|
| 1047 | */ |
|
| 1048 | public function appendToEachKey($prefix): self |
|
| 1049 | { |
|
| 1050 | // init |
|
| 1051 | $result = []; |
|
| 1052 | ||
| 1053 | foreach ($this->getGenerator() as $key => $item) { |
|
| 1054 | if ($item instanceof self) { |
|
| 1055 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 1056 | } elseif (\is_array($item)) { |
|
| 1057 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
| 1058 | ->appendToEachKey($prefix) |
|
| 1059 | ->toArray(); |
|
| 1060 | } else { |
|
| 1061 | $result[$prefix . $key] = $item; |
|
| 1062 | } |
|
| 1063 | } |
|
| 1064 | ||
| 1065 | return self::create( |
|
| 1066 | $result, |
|
| 1067 | $this->iteratorClass, |
|
| 1068 | false |
|
| 1069 | ); |
|
| @@ 4883-4899 (lines=17) @@ | ||
| 4880 | * @psalm-return static<TKey,T> |
|
| 4881 | * @psalm-mutation-free |
|
| 4882 | */ |
|
| 4883 | public function prependToEachKey($suffix): self |
|
| 4884 | { |
|
| 4885 | // init |
|
| 4886 | $result = []; |
|
| 4887 | ||
| 4888 | foreach ($this->getGenerator() as $key => $item) { |
|
| 4889 | if ($item instanceof self) { |
|
| 4890 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 4891 | } elseif (\is_array($item)) { |
|
| 4892 | $result[$key] = self::create( |
|
| 4893 | $item, |
|
| 4894 | $this->iteratorClass, |
|
| 4895 | false |
|
| 4896 | )->prependToEachKey($suffix) |
|
| 4897 | ->toArray(); |
|
| 4898 | } else { |
|
| 4899 | $result[$key . $suffix] = $item; |
|
| 4900 | } |
|
| 4901 | } |
|
| 4902 | ||