| @@ 721-739 (lines=19) @@ | ||
| 718 | * @return static |
|
| 719 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 720 | */ |
|
| 721 | public function appendToEachValue($prefix): self |
|
| 722 | { |
|
| 723 | // init |
|
| 724 | $result = []; |
|
| 725 | ||
| 726 | foreach ($this->getGenerator() as $key => $item) { |
|
| 727 | if ($item instanceof self) { |
|
| 728 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 729 | } elseif (\is_array($item)) { |
|
| 730 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 731 | } elseif (\is_object($item)) { |
|
| 732 | $result[$key] = $item; |
|
| 733 | } else { |
|
| 734 | $result[$key] = $prefix . $item; |
|
| 735 | } |
|
| 736 | } |
|
| 737 | ||
| 738 | return self::create($result, $this->iteratorClass, false); |
|
| 739 | } |
|
| 740 | ||
| 741 | /** |
|
| 742 | * Sort an array in reverse order and maintain index association. |
|
| @@ 2914-2934 (lines=21) @@ | ||
| 2911 | * @return static |
|
| 2912 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2913 | */ |
|
| 2914 | public function prependToEachValue($suffix): self |
|
| 2915 | { |
|
| 2916 | // init |
|
| 2917 | $result = []; |
|
| 2918 | ||
| 2919 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2920 | if ($item instanceof self) { |
|
| 2921 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2922 | } elseif (\is_array($item)) { |
|
| 2923 | $result[$key] = self::create( |
|
| 2924 | $item, |
|
| 2925 | $this->iteratorClass, |
|
| 2926 | false |
|
| 2927 | )->prependToEachValue($suffix) |
|
| 2928 | ->toArray(); |
|
| 2929 | } elseif (\is_object($item)) { |
|
| 2930 | $result[$key] = $item; |
|
| 2931 | } else { |
|
| 2932 | $result[$key] = $item . $suffix; |
|
| 2933 | } |
|
| 2934 | } |
|
| 2935 | ||
| 2936 | return self::create( |
|
| 2937 | $result, |
|