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