@@ 1066-1084 (lines=19) @@ | ||
1063 | * @psalm-return static<TKey,T> |
|
1064 | * @psalm-mutation-free |
|
1065 | */ |
|
1066 | public function appendToEachValue($prefix): self |
|
1067 | { |
|
1068 | // init |
|
1069 | $result = []; |
|
1070 | ||
1071 | foreach ($this->getGenerator() as $key => $item) { |
|
1072 | if ($item instanceof self) { |
|
1073 | $result[$key] = $item->appendToEachValue($prefix); |
|
1074 | } elseif (\is_array($item)) { |
|
1075 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
1076 | } elseif (\is_object($item) === true) { |
|
1077 | $result[$key] = $item; |
|
1078 | } else { |
|
1079 | $result[$key] = $prefix . $item; |
|
1080 | } |
|
1081 | } |
|
1082 | ||
1083 | return self::create($result, $this->iteratorClass, false); |
|
1084 | } |
|
1085 | ||
1086 | /** |
|
1087 | * Sort an array in reverse order and maintain index association. |
|
@@ 4808-4835 (lines=28) @@ | ||
4805 | * @psalm-return static<TKey,T> |
|
4806 | * @psalm-mutation-free |
|
4807 | */ |
|
4808 | public function prependToEachValue($suffix): self |
|
4809 | { |
|
4810 | // init |
|
4811 | $result = []; |
|
4812 | ||
4813 | foreach ($this->getGenerator() as $key => $item) { |
|
4814 | if ($item instanceof self) { |
|
4815 | $result[$key] = $item->prependToEachValue($suffix); |
|
4816 | } elseif (\is_array($item)) { |
|
4817 | $result[$key] = self::create( |
|
4818 | $item, |
|
4819 | $this->iteratorClass, |
|
4820 | false |
|
4821 | )->prependToEachValue($suffix) |
|
4822 | ->toArray(); |
|
4823 | } elseif (\is_object($item) === true) { |
|
4824 | $result[$key] = $item; |
|
4825 | } else { |
|
4826 | $result[$key] = $item . $suffix; |
|
4827 | } |
|
4828 | } |
|
4829 | ||
4830 | return self::create( |
|
4831 | $result, |
|
4832 | $this->iteratorClass, |
|
4833 | false |
|
4834 | ); |
|
4835 | } |
|
4836 | ||
4837 | /** |
|
4838 | * Return the value of a given key and |