| @@ 763-781 (lines=19) @@ | ||
| 760 | * @return static |
|
| 761 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 762 | */ |
|
| 763 | public function appendToEachValue($prefix): self |
|
| 764 | { |
|
| 765 | // init |
|
| 766 | $result = []; |
|
| 767 | ||
| 768 | foreach ($this->getGenerator() as $key => $item) { |
|
| 769 | if ($item instanceof self) { |
|
| 770 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 771 | } elseif (\is_array($item) === true) { |
|
| 772 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 773 | } elseif (\is_object($item) === true) { |
|
| 774 | $result[$key] = $item; |
|
| 775 | } else { |
|
| 776 | $result[$key] = $prefix . $item; |
|
| 777 | } |
|
| 778 | } |
|
| 779 | ||
| 780 | return self::create($result, $this->iteratorClass, false); |
|
| 781 | } |
|
| 782 | ||
| 783 | /** |
|
| 784 | * Sort an array in reverse order and maintain index association. |
|
| @@ 3469-3496 (lines=28) @@ | ||
| 3466 | * @return static |
|
| 3467 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 3468 | */ |
|
| 3469 | public function prependToEachValue($suffix): self |
|
| 3470 | { |
|
| 3471 | // init |
|
| 3472 | $result = []; |
|
| 3473 | ||
| 3474 | foreach ($this->getGenerator() as $key => $item) { |
|
| 3475 | if ($item instanceof self) { |
|
| 3476 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 3477 | } elseif (\is_array($item) === true) { |
|
| 3478 | $result[$key] = self::create( |
|
| 3479 | $item, |
|
| 3480 | $this->iteratorClass, |
|
| 3481 | false |
|
| 3482 | )->prependToEachValue($suffix) |
|
| 3483 | ->toArray(); |
|
| 3484 | } elseif (\is_object($item) === true) { |
|
| 3485 | $result[$key] = $item; |
|
| 3486 | } else { |
|
| 3487 | $result[$key] = $item . $suffix; |
|
| 3488 | } |
|
| 3489 | } |
|
| 3490 | ||
| 3491 | return self::create( |
|
| 3492 | $result, |
|
| 3493 | $this->iteratorClass, |
|
| 3494 | false |
|
| 3495 | ); |
|
| 3496 | } |
|
| 3497 | ||
| 3498 | /** |
|
| 3499 | * Return the value of a given key and |
|