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