| @@ 513-527 (lines=15) @@ | ||
| 510 | * |
|
| 511 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
| 512 | */ |
|
| 513 | public function appendToEachKey($prefix) |
|
| 514 | { |
|
| 515 | $result = []; |
|
| 516 | foreach ($this->array as $key => $item) { |
|
| 517 | if ($item instanceof self) { |
|
| 518 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 519 | } elseif (\is_array($item)) { |
|
| 520 | $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
| 521 | } else { |
|
| 522 | $result[$prefix . $key] = $item; |
|
| 523 | } |
|
| 524 | } |
|
| 525 | ||
| 526 | return self::create($result); |
|
| 527 | } |
|
| 528 | ||
| 529 | /** |
|
| 530 | * Add a prefix to each value. |
|
| @@ 2659-2674 (lines=16) @@ | ||
| 2656 | * |
|
| 2657 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
| 2658 | */ |
|
| 2659 | public function prependToEachKey($suffix) |
|
| 2660 | { |
|
| 2661 | $result = []; |
|
| 2662 | foreach ($this->array as $key => $item) { |
|
| 2663 | if ($item instanceof self) { |
|
| 2664 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 2665 | } elseif (\is_array($item)) { |
|
| 2666 | $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray(); |
|
| 2667 | } else { |
|
| 2668 | $result[$key . $suffix] = $item; |
|
| 2669 | } |
|
| 2670 | ||
| 2671 | } |
|
| 2672 | ||
| 2673 | return self::create($result); |
|
| 2674 | } |
|
| 2675 | ||
| 2676 | /** |
|
| 2677 | * Add a suffix to each value. |
|