| @@ 939-957 (lines=19) @@ | ||
| 936 | * @psalm-return static<TKey,T> | |
| 937 | * @psalm-mutation-free | |
| 938 | */ | |
| 939 | public function appendToEachKey($prefix): self | |
| 940 |     { | |
| 941 | // init | |
| 942 | $result = []; | |
| 943 | ||
| 944 |         foreach ($this->getGenerator() as $key => $item) { | |
| 945 |             if ($item instanceof self) { | |
| 946 | $result[$prefix . $key] = $item->appendToEachKey($prefix); | |
| 947 |             } elseif (\is_array($item) === true) { | |
| 948 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) | |
| 949 | ->appendToEachKey($prefix) | |
| 950 | ->toArray(); | |
| 951 |             } else { | |
| 952 | $result[$prefix . $key] = $item; | |
| 953 | } | |
| 954 | } | |
| 955 | ||
| 956 | return self::create($result, $this->iteratorClass, false); | |
| 957 | } | |
| 958 | ||
| 959 | /** | |
| 960 | * Add a prefix to each value. | |
| @@ 3978-4003 (lines=26) @@ | ||
| 3975 | * @psalm-return static<TKey,T> | |
| 3976 | * @psalm-mutation-free | |
| 3977 | */ | |
| 3978 | public function prependToEachKey($suffix): self | |
| 3979 |     { | |
| 3980 | // init | |
| 3981 | $result = []; | |
| 3982 | ||
| 3983 |         foreach ($this->getGenerator() as $key => $item) { | |
| 3984 |             if ($item instanceof self) { | |
| 3985 | $result[$key] = $item->prependToEachKey($suffix); | |
| 3986 |             } elseif (\is_array($item) === true) { | |
| 3987 | $result[$key] = self::create( | |
| 3988 | $item, | |
| 3989 | $this->iteratorClass, | |
| 3990 | false | |
| 3991 | )->prependToEachKey($suffix) | |
| 3992 | ->toArray(); | |
| 3993 |             } else { | |
| 3994 | $result[$key . $suffix] = $item; | |
| 3995 | } | |
| 3996 | } | |
| 3997 | ||
| 3998 | return self::create( | |
| 3999 | $result, | |
| 4000 | $this->iteratorClass, | |
| 4001 | false | |
| 4002 | ); | |
| 4003 | } | |
| 4004 | ||
| 4005 | /** | |
| 4006 | * Add a suffix to each value. | |