| @@ 737-755 (lines=19) @@ | ||
| 734 | * @return static |
|
| 735 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 736 | */ |
|
| 737 | public function appendToEachValue($prefix): self |
|
| 738 | { |
|
| 739 | // init |
|
| 740 | $result = []; |
|
| 741 | ||
| 742 | foreach ($this->getGenerator() as $key => $item) { |
|
| 743 | if ($item instanceof self) { |
|
| 744 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 745 | } elseif (\is_array($item) === true) { |
|
| 746 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 747 | } elseif (\is_object($item) === true) { |
|
| 748 | $result[$key] = $item; |
|
| 749 | } else { |
|
| 750 | $result[$key] = $prefix . $item; |
|
| 751 | } |
|
| 752 | } |
|
| 753 | ||
| 754 | return self::create($result, $this->iteratorClass, false); |
|
| 755 | } |
|
| 756 | ||
| 757 | /** |
|
| 758 | * Sort an array in reverse order and maintain index association. |
|
| @@ 3361-3388 (lines=28) @@ | ||
| 3358 | * @return static |
|
| 3359 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 3360 | */ |
|
| 3361 | public function prependToEachValue($suffix): self |
|
| 3362 | { |
|
| 3363 | // init |
|
| 3364 | $result = []; |
|
| 3365 | ||
| 3366 | foreach ($this->getGenerator() as $key => $item) { |
|
| 3367 | if ($item instanceof self) { |
|
| 3368 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 3369 | } elseif (\is_array($item) === true) { |
|
| 3370 | $result[$key] = self::create( |
|
| 3371 | $item, |
|
| 3372 | $this->iteratorClass, |
|
| 3373 | false |
|
| 3374 | )->prependToEachValue($suffix) |
|
| 3375 | ->toArray(); |
|
| 3376 | } elseif (\is_object($item) === true) { |
|
| 3377 | $result[$key] = $item; |
|
| 3378 | } else { |
|
| 3379 | $result[$key] = $item . $suffix; |
|
| 3380 | } |
|
| 3381 | } |
|
| 3382 | ||
| 3383 | return self::create( |
|
| 3384 | $result, |
|
| 3385 | $this->iteratorClass, |
|
| 3386 | false |
|
| 3387 | ); |
|
| 3388 | } |
|
| 3389 | ||
| 3390 | /** |
|
| 3391 | * Return the value of a given key and |
|