| @@ 515-531 (lines=17) @@ | ||
| 512 | * |
|
| 513 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 514 | */ |
|
| 515 | public function appendToEachValue($prefix) |
|
| 516 | { |
|
| 517 | $result = []; |
|
| 518 | foreach ($this->array as $key => $item) { |
|
| 519 | if ($item instanceof self) { |
|
| 520 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 521 | } elseif (\is_array($item)) { |
|
| 522 | $result[$key] = self::create($item)->appendToEachValue($prefix)->toArray(); |
|
| 523 | } elseif (\is_object($item)) { |
|
| 524 | $result[$key] = $item; |
|
| 525 | } else { |
|
| 526 | $result[$key] = $prefix . $item; |
|
| 527 | } |
|
| 528 | } |
|
| 529 | ||
| 530 | return self::create($result); |
|
| 531 | } |
|
| 532 | ||
| 533 | /** |
|
| 534 | * Convert an array into a object. |
|
| @@ 2597-2613 (lines=17) @@ | ||
| 2594 | * |
|
| 2595 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2596 | */ |
|
| 2597 | public function prependToEachValue($suffix) |
|
| 2598 | { |
|
| 2599 | $result = []; |
|
| 2600 | foreach ($this->array as $key => $item) { |
|
| 2601 | if ($item instanceof self) { |
|
| 2602 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2603 | } elseif (\is_array($item)) { |
|
| 2604 | $result[$key] = self::create($item)->prependToEachValue($suffix)->toArray(); |
|
| 2605 | } elseif (\is_object($item)) { |
|
| 2606 | $result[$key] = $item; |
|
| 2607 | } else { |
|
| 2608 | $result[$key] = $item . $suffix; |
|
| 2609 | } |
|
| 2610 | } |
|
| 2611 | ||
| 2612 | return self::create($result); |
|
| 2613 | } |
|
| 2614 | ||
| 2615 | /** |
|
| 2616 | * Push one or more values onto the end of array at once. |
|