| @@ 715-733 (lines=19) @@ | ||
| 712 | * @return static |
|
| 713 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 714 | */ |
|
| 715 | public function appendToEachValue($prefix): self |
|
| 716 | { |
|
| 717 | // init |
|
| 718 | $result = []; |
|
| 719 | ||
| 720 | foreach ($this->getGenerator() as $key => $item) { |
|
| 721 | if ($item instanceof self) { |
|
| 722 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 723 | } elseif (\is_array($item) === true) { |
|
| 724 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 725 | } elseif (\is_object($item) === true) { |
|
| 726 | $result[$key] = $item; |
|
| 727 | } else { |
|
| 728 | $result[$key] = $prefix . $item; |
|
| 729 | } |
|
| 730 | } |
|
| 731 | ||
| 732 | return self::create($result, $this->iteratorClass, false); |
|
| 733 | } |
|
| 734 | ||
| 735 | /** |
|
| 736 | * Sort an array in reverse order and maintain index association. |
|
| @@ 3205-3232 (lines=28) @@ | ||
| 3202 | * @return static |
|
| 3203 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 3204 | */ |
|
| 3205 | public function prependToEachValue($suffix): self |
|
| 3206 | { |
|
| 3207 | // init |
|
| 3208 | $result = []; |
|
| 3209 | ||
| 3210 | foreach ($this->getGenerator() as $key => $item) { |
|
| 3211 | if ($item instanceof self) { |
|
| 3212 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 3213 | } elseif (\is_array($item) === true) { |
|
| 3214 | $result[$key] = self::create( |
|
| 3215 | $item, |
|
| 3216 | $this->iteratorClass, |
|
| 3217 | false |
|
| 3218 | )->prependToEachValue($suffix) |
|
| 3219 | ->toArray(); |
|
| 3220 | } elseif (\is_object($item) === true) { |
|
| 3221 | $result[$key] = $item; |
|
| 3222 | } else { |
|
| 3223 | $result[$key] = $item . $suffix; |
|
| 3224 | } |
|
| 3225 | } |
|
| 3226 | ||
| 3227 | return self::create( |
|
| 3228 | $result, |
|
| 3229 | $this->iteratorClass, |
|
| 3230 | false |
|
| 3231 | ); |
|
| 3232 | } |
|
| 3233 | ||
| 3234 | /** |
|
| 3235 | * Return the value of a given key and |
|