@@ 591-607 (lines=17) @@ | ||
588 | * |
|
589 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
590 | */ |
|
591 | public function appendToEachKey($prefix) |
|
592 | { |
|
593 | // init |
|
594 | $result = []; |
|
595 | ||
596 | foreach ($this->getGenerator() as $key => $item) { |
|
597 | if ($item instanceof self) { |
|
598 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
599 | } elseif (\is_array($item)) { |
|
600 | $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
601 | } else { |
|
602 | $result[$prefix . $key] = $item; |
|
603 | } |
|
604 | } |
|
605 | ||
606 | return self::create($result); |
|
607 | } |
|
608 | ||
609 | /** |
|
610 | * Add a prefix to each value. |
|
@@ 2815-2832 (lines=18) @@ | ||
2812 | * |
|
2813 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
2814 | */ |
|
2815 | public function prependToEachKey($suffix) |
|
2816 | { |
|
2817 | // init |
|
2818 | $result = []; |
|
2819 | ||
2820 | foreach ($this->getGenerator() as $key => $item) { |
|
2821 | if ($item instanceof self) { |
|
2822 | $result[$key] = $item->prependToEachKey($suffix); |
|
2823 | } elseif (\is_array($item)) { |
|
2824 | $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray(); |
|
2825 | } else { |
|
2826 | $result[$key . $suffix] = $item; |
|
2827 | } |
|
2828 | ||
2829 | } |
|
2830 | ||
2831 | return self::create($result); |
|
2832 | } |
|
2833 | ||
2834 | /** |
|
2835 | * Add a suffix to each value. |