| @@ 1066-1084 (lines=19) @@ | ||
| 1063 | * @phpstan-return static<TKey,T> |
|
| 1064 | * @psalm-mutation-free |
|
| 1065 | */ |
|
| 1066 | public function appendToEachKey($prefix): self |
|
| 1067 | { |
|
| 1068 | // init |
|
| 1069 | $result = []; |
|
| 1070 | ||
| 1071 | foreach ($this->getGenerator() as $key => $item) { |
|
| 1072 | if ($item instanceof self) { |
|
| 1073 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 1074 | } elseif (\is_array($item)) { |
|
| 1075 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) |
|
| 1076 | ->appendToEachKey($prefix) |
|
| 1077 | ->toArray(); |
|
| 1078 | } else { |
|
| 1079 | $result[$prefix . $key] = $item; |
|
| 1080 | } |
|
| 1081 | } |
|
| 1082 | ||
| 1083 | return self::create( |
|
| 1084 | $result, |
|
| 1085 | $this->iteratorClass, |
|
| 1086 | false |
|
| 1087 | ); |
|
| @@ 4966-4982 (lines=17) @@ | ||
| 4963 | * @phpstan-return static<TKey,T> |
|
| 4964 | * @psalm-mutation-free |
|
| 4965 | */ |
|
| 4966 | public function prependToEachKey($suffix): self |
|
| 4967 | { |
|
| 4968 | // init |
|
| 4969 | $result = []; |
|
| 4970 | ||
| 4971 | foreach ($this->getGenerator() as $key => $item) { |
|
| 4972 | if ($item instanceof self) { |
|
| 4973 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 4974 | } elseif (\is_array($item)) { |
|
| 4975 | $result[$key] = self::create( |
|
| 4976 | $item, |
|
| 4977 | $this->iteratorClass, |
|
| 4978 | false |
|
| 4979 | )->prependToEachKey($suffix) |
|
| 4980 | ->toArray(); |
|
| 4981 | } else { |
|
| 4982 | $result[$key . $suffix] = $item; |
|
| 4983 | } |
|
| 4984 | } |
|
| 4985 | ||