| @@ 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. |
|
| @@ 2877-2897 (lines=21) @@ | ||
| 2874 | * @return static |
|
| 2875 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2876 | */ |
|
| 2877 | public function prependToEachValue($suffix): self |
|
| 2878 | { |
|
| 2879 | // init |
|
| 2880 | $result = []; |
|
| 2881 | ||
| 2882 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2883 | if ($item instanceof self) { |
|
| 2884 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2885 | } elseif (\is_array($item)) { |
|
| 2886 | $result[$key] = self::create( |
|
| 2887 | $item, |
|
| 2888 | $this->iteratorClass, |
|
| 2889 | false |
|
| 2890 | )->prependToEachValue($suffix) |
|
| 2891 | ->toArray(); |
|
| 2892 | } elseif (\is_object($item)) { |
|
| 2893 | $result[$key] = $item; |
|
| 2894 | } else { |
|
| 2895 | $result[$key] = $item . $suffix; |
|
| 2896 | } |
|
| 2897 | } |
|
| 2898 | ||
| 2899 | return self::create( |
|
| 2900 | $result, |
|