| @@ 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. |
|
| @@ 2935-2955 (lines=21) @@ | ||
| 2932 | * @return static |
|
| 2933 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2934 | */ |
|
| 2935 | public function prependToEachValue($suffix): self |
|
| 2936 | { |
|
| 2937 | // init |
|
| 2938 | $result = []; |
|
| 2939 | ||
| 2940 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2941 | if ($item instanceof self) { |
|
| 2942 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2943 | } elseif (\is_array($item)) { |
|
| 2944 | $result[$key] = self::create( |
|
| 2945 | $item, |
|
| 2946 | $this->iteratorClass, |
|
| 2947 | false |
|
| 2948 | )->prependToEachValue($suffix) |
|
| 2949 | ->toArray(); |
|
| 2950 | } elseif (\is_object($item)) { |
|
| 2951 | $result[$key] = $item; |
|
| 2952 | } else { |
|
| 2953 | $result[$key] = $item . $suffix; |
|
| 2954 | } |
|
| 2955 | } |
|
| 2956 | ||
| 2957 | return self::create( |
|
| 2958 | $result, |
|