| @@ 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. |
|
| @@ 2857-2877 (lines=21) @@ | ||
| 2854 | * @return static |
|
| 2855 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2856 | */ |
|
| 2857 | public function prependToEachValue($suffix): self |
|
| 2858 | { |
|
| 2859 | // init |
|
| 2860 | $result = []; |
|
| 2861 | ||
| 2862 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2863 | if ($item instanceof self) { |
|
| 2864 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2865 | } elseif (\is_array($item)) { |
|
| 2866 | $result[$key] = self::create( |
|
| 2867 | $item, |
|
| 2868 | $this->iteratorClass, |
|
| 2869 | false |
|
| 2870 | )->prependToEachValue($suffix) |
|
| 2871 | ->toArray(); |
|
| 2872 | } elseif (\is_object($item)) { |
|
| 2873 | $result[$key] = $item; |
|
| 2874 | } else { |
|
| 2875 | $result[$key] = $item . $suffix; |
|
| 2876 | } |
|
| 2877 | } |
|
| 2878 | ||
| 2879 | return self::create( |
|
| 2880 | $result, |
|