@@ 1105-1123 (lines=19) @@ | ||
1102 | * @phpstan-return static<TKey,T> |
|
1103 | * @psalm-mutation-free |
|
1104 | */ |
|
1105 | public function appendToEachValue($prefix): self |
|
1106 | { |
|
1107 | // init |
|
1108 | $result = []; |
|
1109 | ||
1110 | foreach ($this->getGenerator() as $key => $item) { |
|
1111 | if ($item instanceof self) { |
|
1112 | $result[$key] = $item->appendToEachValue($prefix); |
|
1113 | } elseif (\is_array($item)) { |
|
1114 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
1115 | } elseif (\is_object($item) === true) { |
|
1116 | $result[$key] = $item; |
|
1117 | } else { |
|
1118 | $result[$key] = $prefix . $item; |
|
1119 | } |
|
1120 | } |
|
1121 | ||
1122 | return self::create($result, $this->iteratorClass, false); |
|
1123 | } |
|
1124 | ||
1125 | /** |
|
1126 | * Sort an array in reverse order and maintain index association. |
|
@@ 5025-5052 (lines=28) @@ | ||
5022 | * @phpstan-return static<TKey,T> |
|
5023 | * @psalm-mutation-free |
|
5024 | */ |
|
5025 | public function prependToEachValue($suffix): self |
|
5026 | { |
|
5027 | // init |
|
5028 | $result = []; |
|
5029 | ||
5030 | foreach ($this->getGenerator() as $key => $item) { |
|
5031 | if ($item instanceof self) { |
|
5032 | $result[$key] = $item->prependToEachValue($suffix); |
|
5033 | } elseif (\is_array($item)) { |
|
5034 | $result[$key] = self::create( |
|
5035 | $item, |
|
5036 | $this->iteratorClass, |
|
5037 | false |
|
5038 | )->prependToEachValue($suffix) |
|
5039 | ->toArray(); |
|
5040 | } elseif (\is_object($item) === true) { |
|
5041 | $result[$key] = $item; |
|
5042 | } else { |
|
5043 | $result[$key] = $item . $suffix; |
|
5044 | } |
|
5045 | } |
|
5046 | ||
5047 | return self::create( |
|
5048 | $result, |
|
5049 | $this->iteratorClass, |
|
5050 | false |
|
5051 | ); |
|
5052 | } |
|
5053 | ||
5054 | /** |
|
5055 | * Return the value of a given key and |