@@ 1083-1101 (lines=19) @@ | ||
1080 | * @psalm-return static<TKey,T> |
|
1081 | * @psalm-mutation-free |
|
1082 | */ |
|
1083 | public function appendToEachValue($prefix): self |
|
1084 | { |
|
1085 | // init |
|
1086 | $result = []; |
|
1087 | ||
1088 | foreach ($this->getGenerator() as $key => $item) { |
|
1089 | if ($item instanceof self) { |
|
1090 | $result[$key] = $item->appendToEachValue($prefix); |
|
1091 | } elseif (\is_array($item)) { |
|
1092 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
1093 | } elseif (\is_object($item) === true) { |
|
1094 | $result[$key] = $item; |
|
1095 | } else { |
|
1096 | $result[$key] = $prefix . $item; |
|
1097 | } |
|
1098 | } |
|
1099 | ||
1100 | return self::create($result, $this->iteratorClass, false); |
|
1101 | } |
|
1102 | ||
1103 | /** |
|
1104 | * Sort an array in reverse order and maintain index association. |
|
@@ 4921-4948 (lines=28) @@ | ||
4918 | * @psalm-return static<TKey,T> |
|
4919 | * @psalm-mutation-free |
|
4920 | */ |
|
4921 | public function prependToEachValue($suffix): self |
|
4922 | { |
|
4923 | // init |
|
4924 | $result = []; |
|
4925 | ||
4926 | foreach ($this->getGenerator() as $key => $item) { |
|
4927 | if ($item instanceof self) { |
|
4928 | $result[$key] = $item->prependToEachValue($suffix); |
|
4929 | } elseif (\is_array($item)) { |
|
4930 | $result[$key] = self::create( |
|
4931 | $item, |
|
4932 | $this->iteratorClass, |
|
4933 | false |
|
4934 | )->prependToEachValue($suffix) |
|
4935 | ->toArray(); |
|
4936 | } elseif (\is_object($item) === true) { |
|
4937 | $result[$key] = $item; |
|
4938 | } else { |
|
4939 | $result[$key] = $item . $suffix; |
|
4940 | } |
|
4941 | } |
|
4942 | ||
4943 | return self::create( |
|
4944 | $result, |
|
4945 | $this->iteratorClass, |
|
4946 | false |
|
4947 | ); |
|
4948 | } |
|
4949 | ||
4950 | /** |
|
4951 | * Return the value of a given key and |