| @@ 1049-1067 (lines=19) @@ | ||
| 1046 | * @phpstan-return static<TKey,T> |
|
| 1047 | * @psalm-mutation-free |
|
| 1048 | */ |
|
| 1049 | public function appendToEachKey($prefix): self |
|
| 1050 | { |
|
| 1051 | // init |
|
| 1052 | $result = []; |
|
| 1053 | ||
| 1054 | foreach ($this->getGenerator() as $key => $item) { |
|
| 1055 | if ($item instanceof self) { |
|
| 1056 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 1057 | } elseif (\is_array($item)) { |
|
| 1058 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
| 1059 | ->appendToEachKey($prefix) |
|
| 1060 | ->toArray(); |
|
| 1061 | } else { |
|
| 1062 | $result[$prefix . $key] = $item; |
|
| 1063 | } |
|
| 1064 | } |
|
| 1065 | ||
| 1066 | return self::create( |
|
| 1067 | $result, |
|
| 1068 | $this->iteratorClass, |
|
| 1069 | false |
|
| 1070 | ); |
|
| @@ 4935-4951 (lines=17) @@ | ||
| 4932 | * @phpstan-return static<TKey,T> |
|
| 4933 | * @psalm-mutation-free |
|
| 4934 | */ |
|
| 4935 | public function prependToEachKey($suffix): self |
|
| 4936 | { |
|
| 4937 | // init |
|
| 4938 | $result = []; |
|
| 4939 | ||
| 4940 | foreach ($this->getGenerator() as $key => $item) { |
|
| 4941 | if ($item instanceof self) { |
|
| 4942 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 4943 | } elseif (\is_array($item)) { |
|
| 4944 | $result[$key] = self::create( |
|
| 4945 | $item, |
|
| 4946 | $this->iteratorClass, |
|
| 4947 | false |
|
| 4948 | )->prependToEachKey($suffix) |
|
| 4949 | ->toArray(); |
|
| 4950 | } else { |
|
| 4951 | $result[$key . $suffix] = $item; |
|
| 4952 | } |
|
| 4953 | } |
|
| 4954 | ||