| @@ 745-763 (lines=19) @@ | ||
| 742 | * @return static |
|
| 743 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 744 | */ |
|
| 745 | public function appendToEachValue($prefix): self |
|
| 746 | { |
|
| 747 | // init |
|
| 748 | $result = []; |
|
| 749 | ||
| 750 | foreach ($this->getGenerator() as $key => $item) { |
|
| 751 | if ($item instanceof self) { |
|
| 752 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 753 | } elseif (\is_array($item) === true) { |
|
| 754 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
| 755 | } elseif (\is_object($item) === true) { |
|
| 756 | $result[$key] = $item; |
|
| 757 | } else { |
|
| 758 | $result[$key] = $prefix . $item; |
|
| 759 | } |
|
| 760 | } |
|
| 761 | ||
| 762 | return self::create($result, $this->iteratorClass, false); |
|
| 763 | } |
|
| 764 | ||
| 765 | /** |
|
| 766 | * Sort an array in reverse order and maintain index association. |
|
| @@ 3400-3427 (lines=28) @@ | ||
| 3397 | * @return static |
|
| 3398 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 3399 | */ |
|
| 3400 | public function prependToEachValue($suffix): self |
|
| 3401 | { |
|
| 3402 | // init |
|
| 3403 | $result = []; |
|
| 3404 | ||
| 3405 | foreach ($this->getGenerator() as $key => $item) { |
|
| 3406 | if ($item instanceof self) { |
|
| 3407 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 3408 | } elseif (\is_array($item) === true) { |
|
| 3409 | $result[$key] = self::create( |
|
| 3410 | $item, |
|
| 3411 | $this->iteratorClass, |
|
| 3412 | false |
|
| 3413 | )->prependToEachValue($suffix) |
|
| 3414 | ->toArray(); |
|
| 3415 | } elseif (\is_object($item) === true) { |
|
| 3416 | $result[$key] = $item; |
|
| 3417 | } else { |
|
| 3418 | $result[$key] = $item . $suffix; |
|
| 3419 | } |
|
| 3420 | } |
|
| 3421 | ||
| 3422 | return self::create( |
|
| 3423 | $result, |
|
| 3424 | $this->iteratorClass, |
|
| 3425 | false |
|
| 3426 | ); |
|
| 3427 | } |
|
| 3428 | ||
| 3429 | /** |
|
| 3430 | * Return the value of a given key and |
|