| @@ 717-735 (lines=19) @@ | ||
| 714 | * @return static | |
| 715 | * <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> | |
| 716 | */ | |
| 717 | public function appendToEachKey($prefix): self | |
| 718 |     { | |
| 719 | // init | |
| 720 | $result = []; | |
| 721 | ||
| 722 |         foreach ($this->getGenerator() as $key => $item) { | |
| 723 |             if ($item instanceof self) { | |
| 724 | $result[$prefix . $key] = $item->appendToEachKey($prefix); | |
| 725 |             } elseif (\is_array($item) === true) { | |
| 726 | $result[$prefix . $key] = self::create($item, $this->iteratorClass, false) | |
| 727 | ->appendToEachKey($prefix) | |
| 728 | ->toArray(); | |
| 729 |             } else { | |
| 730 | $result[$prefix . $key] = $item; | |
| 731 | } | |
| 732 | } | |
| 733 | ||
| 734 | return self::create($result, $this->iteratorClass, false); | |
| 735 | } | |
| 736 | ||
| 737 | /** | |
| 738 | * Add a prefix to each value. | |
| @@ 3365-3390 (lines=26) @@ | ||
| 3362 | * @return static | |
| 3363 | * <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> | |
| 3364 | */ | |
| 3365 | public function prependToEachKey($suffix): self | |
| 3366 |     { | |
| 3367 | // init | |
| 3368 | $result = []; | |
| 3369 | ||
| 3370 |         foreach ($this->getGenerator() as $key => $item) { | |
| 3371 |             if ($item instanceof self) { | |
| 3372 | $result[$key] = $item->prependToEachKey($suffix); | |
| 3373 |             } elseif (\is_array($item) === true) { | |
| 3374 | $result[$key] = self::create( | |
| 3375 | $item, | |
| 3376 | $this->iteratorClass, | |
| 3377 | false | |
| 3378 | )->prependToEachKey($suffix) | |
| 3379 | ->toArray(); | |
| 3380 |             } else { | |
| 3381 | $result[$key . $suffix] = $item; | |
| 3382 | } | |
| 3383 | } | |
| 3384 | ||
| 3385 | return self::create( | |
| 3386 | $result, | |
| 3387 | $this->iteratorClass, | |
| 3388 | false | |
| 3389 | ); | |
| 3390 | } | |
| 3391 | ||
| 3392 | /** | |
| 3393 | * Add a suffix to each value. | |