| @@ 2798-2818 (lines=21) @@ | ||
| 2795 | * @return static |
|
| 2796 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2797 | */ |
|
| 2798 | public function prependToEachValue($suffix): self |
|
| 2799 | { |
|
| 2800 | // init |
|
| 2801 | $result = []; |
|
| 2802 | ||
| 2803 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2804 | if ($item instanceof self) { |
|
| 2805 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2806 | } elseif (\is_array($item)) { |
|
| 2807 | $result[$key] = self::create( |
|
| 2808 | $item, |
|
| 2809 | $this->iteratorClass, |
|
| 2810 | false |
|
| 2811 | )->prependToEachValue($suffix) |
|
| 2812 | ->toArray(); |
|
| 2813 | } elseif (\is_object($item)) { |
|
| 2814 | $result[$key] = $item; |
|
| 2815 | } else { |
|
| 2816 | $result[$key] = $item . $suffix; |
|
| 2817 | } |
|
| 2818 | } |
|
| 2819 | ||
| 2820 | return self::create( |
|
| 2821 | $result, |
|
| @@ 700-718 (lines=19) @@ | ||
| 697 | * @return static |
|
| 698 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 699 | */ |
|
| 700 | public function appendToEachValue($prefix): self |
|
| 701 | { |
|
| 702 | // init |
|
| 703 | $result = []; |
|
| 704 | ||
| 705 | foreach ($this->getGenerator() as $key => $item) { |
|
| 706 | if ($item instanceof self) { |
|
| 707 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 708 | } elseif (\is_array($item)) { |
|
| 709 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 710 | } elseif (\is_object($item)) { |
|
| 711 | $result[$key] = $item; |
|
| 712 | } else { |
|
| 713 | $result[$key] = $prefix . $item; |
|
| 714 | } |
|
| 715 | } |
|
| 716 | ||
| 717 | return self::create($result, $this->iteratorClass, false); |
|
| 718 | } |
|
| 719 | ||
| 720 | /** |
|
| 721 | * Sort an array in reverse order and maintain index association. |
|