@@ 1005-1023 (lines=19) @@ | ||
1002 | * @psalm-return static<TKey,T> |
|
1003 | * @psalm-mutation-free |
|
1004 | */ |
|
1005 | public function appendToEachValue($prefix): self |
|
1006 | { |
|
1007 | // init |
|
1008 | $result = []; |
|
1009 | ||
1010 | foreach ($this->getGenerator() as $key => $item) { |
|
1011 | if ($item instanceof self) { |
|
1012 | $result[$key] = $item->appendToEachValue($prefix); |
|
1013 | } elseif (\is_array($item) === true) { |
|
1014 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
1015 | } elseif (\is_object($item) === true) { |
|
1016 | $result[$key] = $item; |
|
1017 | } else { |
|
1018 | $result[$key] = $prefix . $item; |
|
1019 | } |
|
1020 | } |
|
1021 | ||
1022 | return self::create($result, $this->iteratorClass, false); |
|
1023 | } |
|
1024 | ||
1025 | /** |
|
1026 | * Sort an array in reverse order and maintain index association. |
|
@@ 4339-4366 (lines=28) @@ | ||
4336 | * @psalm-return static<TKey,T> |
|
4337 | * @psalm-mutation-free |
|
4338 | */ |
|
4339 | public function prependToEachValue($suffix): self |
|
4340 | { |
|
4341 | // init |
|
4342 | $result = []; |
|
4343 | ||
4344 | foreach ($this->getGenerator() as $key => $item) { |
|
4345 | if ($item instanceof self) { |
|
4346 | $result[$key] = $item->prependToEachValue($suffix); |
|
4347 | } elseif (\is_array($item) === true) { |
|
4348 | $result[$key] = self::create( |
|
4349 | $item, |
|
4350 | $this->iteratorClass, |
|
4351 | false |
|
4352 | )->prependToEachValue($suffix) |
|
4353 | ->toArray(); |
|
4354 | } elseif (\is_object($item) === true) { |
|
4355 | $result[$key] = $item; |
|
4356 | } else { |
|
4357 | $result[$key] = $item . $suffix; |
|
4358 | } |
|
4359 | } |
|
4360 | ||
4361 | return self::create( |
|
4362 | $result, |
|
4363 | $this->iteratorClass, |
|
4364 | false |
|
4365 | ); |
|
4366 | } |
|
4367 | ||
4368 | /** |
|
4369 | * Return the value of a given key and |