| @@ 609-625 (lines=17) @@ | ||
| 606 | * |
|
| 607 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 608 | */ |
|
| 609 | public function appendToEachValue($prefix) |
|
| 610 | { |
|
| 611 | $result = []; |
|
| 612 | foreach ($this->array as $key => $item) { |
|
| 613 | if ($item instanceof self) { |
|
| 614 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 615 | } elseif (\is_array($item)) { |
|
| 616 | $result[$key] = self::create($item)->appendToEachValue($prefix)->toArray(); |
|
| 617 | } elseif (\is_object($item)) { |
|
| 618 | $result[$key] = $item; |
|
| 619 | } else { |
|
| 620 | $result[$key] = $prefix . $item; |
|
| 621 | } |
|
| 622 | } |
|
| 623 | ||
| 624 | return self::create($result); |
|
| 625 | } |
|
| 626 | ||
| 627 | /** |
|
| 628 | * Convert an array into a object. |
|
| @@ 2791-2807 (lines=17) @@ | ||
| 2788 | * |
|
| 2789 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2790 | */ |
|
| 2791 | public function prependToEachValue($suffix) |
|
| 2792 | { |
|
| 2793 | $result = []; |
|
| 2794 | foreach ($this->array as $key => $item) { |
|
| 2795 | if ($item instanceof self) { |
|
| 2796 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2797 | } elseif (\is_array($item)) { |
|
| 2798 | $result[$key] = self::create($item)->prependToEachValue($suffix)->toArray(); |
|
| 2799 | } elseif (\is_object($item)) { |
|
| 2800 | $result[$key] = $item; |
|
| 2801 | } else { |
|
| 2802 | $result[$key] = $item . $suffix; |
|
| 2803 | } |
|
| 2804 | } |
|
| 2805 | ||
| 2806 | return self::create($result); |
|
| 2807 | } |
|
| 2808 | ||
| 2809 | /** |
|
| 2810 | * Push one or more values onto the end of array at once. |
|