| @@ 1082-1100 (lines=19) @@ | ||
| 1079 | * @phpstan-return static<TKey,T> | |
| 1080 | * @psalm-mutation-free | |
| 1081 | */ | |
| 1082 | public function appendToEachValue($prefix): self | |
| 1083 |     { | |
| 1084 | // init | |
| 1085 | $result = []; | |
| 1086 | ||
| 1087 |         foreach ($this->getGenerator() as $key => $item) { | |
| 1088 |             if ($item instanceof self) { | |
| 1089 | $result[$key] = $item->appendToEachValue($prefix); | |
| 1090 |             } elseif (\is_array($item)) { | |
| 1091 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); | |
| 1092 |             } elseif (\is_object($item) === true) { | |
| 1093 | $result[$key] = $item; | |
| 1094 |             } else { | |
| 1095 | $result[$key] = $prefix . $item; | |
| 1096 | } | |
| 1097 | } | |
| 1098 | ||
| 1099 | return self::create($result, $this->iteratorClass, false); | |
| 1100 | } | |
| 1101 | ||
| 1102 | /** | |
| 1103 | * Sort an array in reverse order and maintain index association. | |
| @@ 4974-5001 (lines=28) @@ | ||
| 4971 | * @phpstan-return static<TKey,T> | |
| 4972 | * @psalm-mutation-free | |
| 4973 | */ | |
| 4974 | public function prependToEachValue($suffix): self | |
| 4975 |     { | |
| 4976 | // init | |
| 4977 | $result = []; | |
| 4978 | ||
| 4979 |         foreach ($this->getGenerator() as $key => $item) { | |
| 4980 |             if ($item instanceof self) { | |
| 4981 | $result[$key] = $item->prependToEachValue($suffix); | |
| 4982 |             } elseif (\is_array($item)) { | |
| 4983 | $result[$key] = self::create( | |
| 4984 | $item, | |
| 4985 | $this->iteratorClass, | |
| 4986 | false | |
| 4987 | )->prependToEachValue($suffix) | |
| 4988 | ->toArray(); | |
| 4989 |             } elseif (\is_object($item) === true) { | |
| 4990 | $result[$key] = $item; | |
| 4991 |             } else { | |
| 4992 | $result[$key] = $item . $suffix; | |
| 4993 | } | |
| 4994 | } | |
| 4995 | ||
| 4996 | return self::create( | |
| 4997 | $result, | |
| 4998 | $this->iteratorClass, | |
| 4999 | false | |
| 5000 | ); | |
| 5001 | } | |
| 5002 | ||
| 5003 | /** | |
| 5004 | * Return the value of a given key and | |