| @@ 659-677 (lines=19) @@ | ||
| 656 | * @return static |
|
| 657 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 658 | */ |
|
| 659 | public function appendToEachValue($prefix): self |
|
| 660 | { |
|
| 661 | // init |
|
| 662 | $result = []; |
|
| 663 | ||
| 664 | foreach ($this->getGenerator() as $key => $item) { |
|
| 665 | if ($item instanceof self) { |
|
| 666 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 667 | } elseif (\is_array($item)) { |
|
| 668 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 669 | } elseif (\is_object($item)) { |
|
| 670 | $result[$key] = $item; |
|
| 671 | } else { |
|
| 672 | $result[$key] = $prefix . $item; |
|
| 673 | } |
|
| 674 | } |
|
| 675 | ||
| 676 | return self::create($result, $this->iteratorClass, false); |
|
| 677 | } |
|
| 678 | ||
| 679 | /** |
|
| 680 | * Sort an array in reverse order and maintain index association. |
|
| @@ 2610-2630 (lines=21) @@ | ||
| 2607 | * @return static |
|
| 2608 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2609 | */ |
|
| 2610 | public function prependToEachValue($suffix): self |
|
| 2611 | { |
|
| 2612 | // init |
|
| 2613 | $result = []; |
|
| 2614 | ||
| 2615 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2616 | if ($item instanceof self) { |
|
| 2617 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2618 | } elseif (\is_array($item)) { |
|
| 2619 | $result[$key] = self::create($item, $this->iteratorClass, false) |
|
| 2620 | ->prependToEachValue($suffix) |
|
| 2621 | ->toArray(); |
|
| 2622 | } elseif (\is_object($item)) { |
|
| 2623 | $result[$key] = $item; |
|
| 2624 | } else { |
|
| 2625 | $result[$key] = $item . $suffix; |
|
| 2626 | } |
|
| 2627 | } |
|
| 2628 | ||
| 2629 | return self::create($result, $this->iteratorClass, false); |
|
| 2630 | } |
|
| 2631 | ||
| 2632 | /** |
|
| 2633 | * Push one or more values onto the end of array at once. |
|