| @@ 654-672 (lines=19) @@ | ||
| 651 | * @return static |
|
| 652 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 653 | */ |
|
| 654 | public function appendToEachValue($prefix) |
|
| 655 | { |
|
| 656 | // init |
|
| 657 | $result = []; |
|
| 658 | ||
| 659 | foreach ($this->getGenerator() as $key => $item) { |
|
| 660 | if ($item instanceof self) { |
|
| 661 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 662 | } elseif (\is_array($item)) { |
|
| 663 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 664 | } elseif (\is_object($item)) { |
|
| 665 | $result[$key] = $item; |
|
| 666 | } else { |
|
| 667 | $result[$key] = $prefix . $item; |
|
| 668 | } |
|
| 669 | } |
|
| 670 | ||
| 671 | return self::create($result, $this->iteratorClass, false); |
|
| 672 | } |
|
| 673 | ||
| 674 | /** |
|
| 675 | * Convert an array into a object. |
|
| @@ 3012-3032 (lines=21) @@ | ||
| 3009 | * @return static |
|
| 3010 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 3011 | */ |
|
| 3012 | public function prependToEachValue($suffix) |
|
| 3013 | { |
|
| 3014 | // init |
|
| 3015 | $result = []; |
|
| 3016 | ||
| 3017 | foreach ($this->getGenerator() as $key => $item) { |
|
| 3018 | if ($item instanceof self) { |
|
| 3019 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 3020 | } elseif (\is_array($item)) { |
|
| 3021 | $result[$key] = self::create($item, $this->iteratorClass, false) |
|
| 3022 | ->prependToEachValue($suffix) |
|
| 3023 | ->toArray(); |
|
| 3024 | } elseif (\is_object($item)) { |
|
| 3025 | $result[$key] = $item; |
|
| 3026 | } else { |
|
| 3027 | $result[$key] = $item . $suffix; |
|
| 3028 | } |
|
| 3029 | } |
|
| 3030 | ||
| 3031 | return self::create($result, $this->iteratorClass, false); |
|
| 3032 | } |
|
| 3033 | ||
| 3034 | /** |
|
| 3035 | * Push one or more values onto the end of array at once. |
|