@@ 514-530 (lines=17) @@ | ||
511 | * |
|
512 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
513 | */ |
|
514 | public function appendToEachValue($prefix) |
|
515 | { |
|
516 | $result = array(); |
|
517 | foreach ($this->array as $key => $item) { |
|
518 | if ($item instanceof self) { |
|
519 | $result[$key] = $item->appendToEachValue($prefix); |
|
520 | } elseif (\is_array($item)) { |
|
521 | $result[$key] = self::create($item)->appendToEachValue($prefix)->toArray(); |
|
522 | } elseif (\is_object($item)) { |
|
523 | $result[$key] = $item; |
|
524 | } else { |
|
525 | $result[$key] = $prefix . $item; |
|
526 | } |
|
527 | } |
|
528 | ||
529 | return self::create($result); |
|
530 | } |
|
531 | ||
532 | /** |
|
533 | * Convert an array into a object. |
|
@@ 2626-2642 (lines=17) @@ | ||
2623 | * |
|
2624 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
2625 | */ |
|
2626 | public function prependToEachValue($suffix) |
|
2627 | { |
|
2628 | $result = array(); |
|
2629 | foreach ($this->array as $key => $item) { |
|
2630 | if ($item instanceof self) { |
|
2631 | $result[$key] = $item->prependToEachValue($suffix); |
|
2632 | } elseif (\is_array($item)) { |
|
2633 | $result[$key] = self::create($item)->prependToEachValue($suffix)->toArray(); |
|
2634 | } elseif (\is_object($item)) { |
|
2635 | $result[$key] = $item; |
|
2636 | } else { |
|
2637 | $result[$key] = $item . $suffix; |
|
2638 | } |
|
2639 | } |
|
2640 | ||
2641 | return self::create($result); |
|
2642 | } |
|
2643 | ||
2644 | /** |
|
2645 | * Push one or more values onto the end of array at once. |