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