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