| @@ 715-733 (lines=19) @@ | ||
| 712 | * @return static |
|
| 713 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 714 | */ |
|
| 715 | public function appendToEachValue($prefix): self |
|
| 716 | { |
|
| 717 | // init |
|
| 718 | $result = []; |
|
| 719 | ||
| 720 | foreach ($this->getGenerator() as $key => $item) { |
|
| 721 | if ($item instanceof self) { |
|
| 722 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 723 | } elseif (\is_array($item)) { |
|
| 724 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 725 | } elseif (\is_object($item)) { |
|
| 726 | $result[$key] = $item; |
|
| 727 | } else { |
|
| 728 | $result[$key] = $prefix . $item; |
|
| 729 | } |
|
| 730 | } |
|
| 731 | ||
| 732 | return self::create($result, $this->iteratorClass, false); |
|
| 733 | } |
|
| 734 | ||
| 735 | /** |
|
| 736 | * Sort an array in reverse order and maintain index association. |
|
| @@ 2989-3009 (lines=21) @@ | ||
| 2986 | * @return static |
|
| 2987 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2988 | */ |
|
| 2989 | public function prependToEachValue($suffix): self |
|
| 2990 | { |
|
| 2991 | // init |
|
| 2992 | $result = []; |
|
| 2993 | ||
| 2994 | foreach ($this->getGenerator() as $key => $item) { |
|
| 2995 | if ($item instanceof self) { |
|
| 2996 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2997 | } elseif (\is_array($item)) { |
|
| 2998 | $result[$key] = self::create( |
|
| 2999 | $item, |
|
| 3000 | $this->iteratorClass, |
|
| 3001 | false |
|
| 3002 | )->prependToEachValue($suffix) |
|
| 3003 | ->toArray(); |
|
| 3004 | } elseif (\is_object($item)) { |
|
| 3005 | $result[$key] = $item; |
|
| 3006 | } else { |
|
| 3007 | $result[$key] = $item . $suffix; |
|
| 3008 | } |
|
| 3009 | } |
|
| 3010 | ||
| 3011 | return self::create( |
|
| 3012 | $result, |
|