| @@ 1018-1036 (lines=19) @@ | ||
| 1015 | * @psalm-return static<TKey,T> | |
| 1016 | * @psalm-mutation-free | |
| 1017 | */ | |
| 1018 | public function appendToEachKey($prefix): self | |
| 1019 |     { | |
| 1020 | // init | |
| 1021 | $result = []; | |
| 1022 | ||
| 1023 |         foreach ($this->getGenerator() as $key => $item) { | |
| 1024 |             if ($item instanceof self) { | |
| 1025 | $result[$prefix . $key] = $item->appendToEachKey($prefix); | |
| 1026 |             } elseif (\is_array($item) === true) { | |
| 1027 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) | |
| 1028 | ->appendToEachKey($prefix) | |
| 1029 | ->toArray(); | |
| 1030 |             } else { | |
| 1031 | $result[$prefix . $key] = $item; | |
| 1032 | } | |
| 1033 | } | |
| 1034 | ||
| 1035 | return self::create($result, $this->iteratorClass, false); | |
| 1036 | } | |
| 1037 | ||
| 1038 | /** | |
| 1039 | * Add a prefix to each value. | |
| @@ 4425-4450 (lines=26) @@ | ||
| 4422 | * @psalm-return static<TKey,T> | |
| 4423 | * @psalm-mutation-free | |
| 4424 | */ | |
| 4425 | public function prependToEachKey($suffix): self | |
| 4426 |     { | |
| 4427 | // init | |
| 4428 | $result = []; | |
| 4429 | ||
| 4430 |         foreach ($this->getGenerator() as $key => $item) { | |
| 4431 |             if ($item instanceof self) { | |
| 4432 | $result[$key] = $item->prependToEachKey($suffix); | |
| 4433 |             } elseif (\is_array($item) === true) { | |
| 4434 | $result[$key] = self::create( | |
| 4435 | $item, | |
| 4436 | $this->iteratorClass, | |
| 4437 | false | |
| 4438 | )->prependToEachKey($suffix) | |
| 4439 | ->toArray(); | |
| 4440 |             } else { | |
| 4441 | $result[$key . $suffix] = $item; | |
| 4442 | } | |
| 4443 | } | |
| 4444 | ||
| 4445 | return self::create( | |
| 4446 | $result, | |
| 4447 | $this->iteratorClass, | |
| 4448 | false | |
| 4449 | ); | |
| 4450 | } | |
| 4451 | ||
| 4452 | /** | |
| 4453 | * Add a suffix to each value. | |