@@ 736-754 (lines=19) @@ | ||
733 | * @return static |
|
734 | * <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
735 | */ |
|
736 | public function appendToEachValue($prefix): self |
|
737 | { |
|
738 | // init |
|
739 | $result = []; |
|
740 | ||
741 | foreach ($this->getGenerator() as $key => $item) { |
|
742 | if ($item instanceof self) { |
|
743 | $result[$key] = $item->appendToEachValue($prefix); |
|
744 | } elseif (\is_array($item) === true) { |
|
745 | $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray(); |
|
746 | } elseif (\is_object($item) === true) { |
|
747 | $result[$key] = $item; |
|
748 | } else { |
|
749 | $result[$key] = $prefix . $item; |
|
750 | } |
|
751 | } |
|
752 | ||
753 | return self::create($result, $this->iteratorClass, false); |
|
754 | } |
|
755 | ||
756 | /** |
|
757 | * Sort an array in reverse order and maintain index association. |
|
@@ 3376-3403 (lines=28) @@ | ||
3373 | * @return static |
|
3374 | * <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
3375 | */ |
|
3376 | public function prependToEachValue($suffix): self |
|
3377 | { |
|
3378 | // init |
|
3379 | $result = []; |
|
3380 | ||
3381 | foreach ($this->getGenerator() as $key => $item) { |
|
3382 | if ($item instanceof self) { |
|
3383 | $result[$key] = $item->prependToEachValue($suffix); |
|
3384 | } elseif (\is_array($item) === true) { |
|
3385 | $result[$key] = self::create( |
|
3386 | $item, |
|
3387 | $this->iteratorClass, |
|
3388 | false |
|
3389 | )->prependToEachValue($suffix) |
|
3390 | ->toArray(); |
|
3391 | } elseif (\is_object($item) === true) { |
|
3392 | $result[$key] = $item; |
|
3393 | } else { |
|
3394 | $result[$key] = $item . $suffix; |
|
3395 | } |
|
3396 | } |
|
3397 | ||
3398 | return self::create( |
|
3399 | $result, |
|
3400 | $this->iteratorClass, |
|
3401 | false |
|
3402 | ); |
|
3403 | } |
|
3404 | ||
3405 | /** |
|
3406 | * Return the value of a given key and |