@@ 988-1006 (lines=19) @@ | ||
985 | * @psalm-return static<TKey,T> |
|
986 | * @psalm-mutation-free |
|
987 | */ |
|
988 | public function appendToEachValue($prefix): self |
|
989 | { |
|
990 | // init |
|
991 | $result = []; |
|
992 | ||
993 | foreach ($this->getGenerator() as $key => $item) { |
|
994 | if ($item instanceof self) { |
|
995 | $result[$key] = $item->appendToEachValue($prefix); |
|
996 | } elseif (\is_array($item) === true) { |
|
997 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
998 | } elseif (\is_object($item) === true) { |
|
999 | $result[$key] = $item; |
|
1000 | } else { |
|
1001 | $result[$key] = $prefix . $item; |
|
1002 | } |
|
1003 | } |
|
1004 | ||
1005 | return self::create($result, $this->iteratorClass, false); |
|
1006 | } |
|
1007 | ||
1008 | /** |
|
1009 | * Sort an array in reverse order and maintain index association. |
|
@@ 4148-4175 (lines=28) @@ | ||
4145 | * @psalm-return static<TKey,T> |
|
4146 | * @psalm-mutation-free |
|
4147 | */ |
|
4148 | public function prependToEachValue($suffix): self |
|
4149 | { |
|
4150 | // init |
|
4151 | $result = []; |
|
4152 | ||
4153 | foreach ($this->getGenerator() as $key => $item) { |
|
4154 | if ($item instanceof self) { |
|
4155 | $result[$key] = $item->prependToEachValue($suffix); |
|
4156 | } elseif (\is_array($item) === true) { |
|
4157 | $result[$key] = self::create( |
|
4158 | $item, |
|
4159 | $this->iteratorClass, |
|
4160 | false |
|
4161 | )->prependToEachValue($suffix) |
|
4162 | ->toArray(); |
|
4163 | } elseif (\is_object($item) === true) { |
|
4164 | $result[$key] = $item; |
|
4165 | } else { |
|
4166 | $result[$key] = $item . $suffix; |
|
4167 | } |
|
4168 | } |
|
4169 | ||
4170 | return self::create( |
|
4171 | $result, |
|
4172 | $this->iteratorClass, |
|
4173 | false |
|
4174 | ); |
|
4175 | } |
|
4176 | ||
4177 | /** |
|
4178 | * Return the value of a given key and |