| @@ 616-634 (lines=19) @@ | ||
| 613 | * |
|
| 614 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 615 | */ |
|
| 616 | public function appendToEachValue($prefix) |
|
| 617 | { |
|
| 618 | // init |
|
| 619 | $result = []; |
|
| 620 | ||
| 621 | foreach ($this->getGenerator() as $key => $item) { |
|
| 622 | if ($item instanceof self) { |
|
| 623 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 624 | } elseif (\is_array($item)) { |
|
| 625 | $result[$key] = self::create($item)->appendToEachValue($prefix)->toArray(); |
|
| 626 | } elseif (\is_object($item)) { |
|
| 627 | $result[$key] = $item; |
|
| 628 | } else { |
|
| 629 | $result[$key] = $prefix . $item; |
|
| 630 | } |
|
| 631 | } |
|
| 632 | ||
| 633 | return self::create($result); |
|
| 634 | } |
|
| 635 | ||
| 636 | /** |
|
| 637 | * Convert an array into a object. |
|
| @@ 2841-2859 (lines=19) @@ | ||
| 2838 | * |
|
| 2839 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2840 | */ |
|
| 2841 | public function prependToEachValue($suffix) |
|
| 2842 | { |
|
| 2843 | // init |
|
| 2844 | $result = []; |
|
| 2845 | ||
| 2846 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2847 | if ($item instanceof self) { |
|
| 2848 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2849 | } elseif (\is_array($item)) { |
|
| 2850 | $result[$key] = self::create($item)->prependToEachValue($suffix)->toArray(); |
|
| 2851 | } elseif (\is_object($item)) { |
|
| 2852 | $result[$key] = $item; |
|
| 2853 | } else { |
|
| 2854 | $result[$key] = $item . $suffix; |
|
| 2855 | } |
|
| 2856 | } |
|
| 2857 | ||
| 2858 | return self::create($result); |
|
| 2859 | } |
|
| 2860 | ||
| 2861 | /** |
|
| 2862 | * Push one or more values onto the end of array at once. |
|