@@ 1070-1088 (lines=19) @@ | ||
1067 | * @phpstan-return static<TKey,T> |
|
1068 | * @psalm-mutation-free |
|
1069 | */ |
|
1070 | public function appendToEachKey($prefix): self |
|
1071 | { |
|
1072 | // init |
|
1073 | $result = []; |
|
1074 | ||
1075 | foreach ($this->getGenerator() as $key => $item) { |
|
1076 | if ($item instanceof self) { |
|
1077 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
1078 | } elseif (\is_array($item)) { |
|
1079 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
1080 | ->appendToEachKey($prefix) |
|
1081 | ->toArray(); |
|
1082 | } else { |
|
1083 | $result[$prefix . $key] = $item; |
|
1084 | } |
|
1085 | } |
|
1086 | ||
1087 | return self::create( |
|
1088 | $result, |
|
1089 | $this->iteratorClass, |
|
1090 | false |
|
1091 | ); |
|
@@ 4987-5003 (lines=17) @@ | ||
4984 | * @phpstan-return static<TKey,T> |
|
4985 | * @psalm-mutation-free |
|
4986 | */ |
|
4987 | public function prependToEachKey($suffix): self |
|
4988 | { |
|
4989 | // init |
|
4990 | $result = []; |
|
4991 | ||
4992 | foreach ($this->getGenerator() as $key => $item) { |
|
4993 | if ($item instanceof self) { |
|
4994 | $result[$key] = $item->prependToEachKey($suffix); |
|
4995 | } elseif (\is_array($item)) { |
|
4996 | $result[$key] = self::create( |
|
4997 | $item, |
|
4998 | $this->iteratorClass, |
|
4999 | false |
|
5000 | )->prependToEachKey($suffix) |
|
5001 | ->toArray(); |
|
5002 | } else { |
|
5003 | $result[$key . $suffix] = $item; |
|
5004 | } |
|
5005 | } |
|
5006 |