| @@ 492-506 (lines=15) @@ | ||
| 489 | * |
|
| 490 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p> |
|
| 491 | */ |
|
| 492 | public function appendToEachKey($prefix) |
|
| 493 | { |
|
| 494 | $result = []; |
|
| 495 | foreach ($this->array as $key => $item) { |
|
| 496 | if ($item instanceof self) { |
|
| 497 | $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
| 498 | } elseif (\is_array($item)) { |
|
| 499 | $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
| 500 | } else { |
|
| 501 | $result[$prefix . $key] = $item; |
|
| 502 | } |
|
| 503 | } |
|
| 504 | ||
| 505 | return self::create($result); |
|
| 506 | } |
|
| 507 | ||
| 508 | /** |
|
| 509 | * Add a prefix to each value. |
|
| @@ 2573-2588 (lines=16) @@ | ||
| 2570 | * |
|
| 2571 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p> |
|
| 2572 | */ |
|
| 2573 | public function prependToEachKey($suffix) |
|
| 2574 | { |
|
| 2575 | $result = []; |
|
| 2576 | foreach ($this->array as $key => $item) { |
|
| 2577 | if ($item instanceof self) { |
|
| 2578 | $result[$key] = $item->prependToEachKey($suffix); |
|
| 2579 | } elseif (\is_array($item)) { |
|
| 2580 | $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray(); |
|
| 2581 | } else { |
|
| 2582 | $result[$key . $suffix] = $item; |
|
| 2583 | } |
|
| 2584 | ||
| 2585 | } |
|
| 2586 | ||
| 2587 | return self::create($result); |
|
| 2588 | } |
|
| 2589 | ||
| 2590 | /** |
|
| 2591 | * Add a suffix to each value. |
|