| @@ 512-528 (lines=17) @@ | ||
| 509 | * |
|
| 510 | * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p> |
|
| 511 | */ |
|
| 512 | public function appendToEachValue($prefix) |
|
| 513 | { |
|
| 514 | $result = array(); |
|
| 515 | foreach ($this->array as $key => $item) { |
|
| 516 | if ($item instanceof self) { |
|
| 517 | $result[$key] = $item->appendToEachValue($prefix); |
|
| 518 | } else if (is_array($item)) { |
|
| 519 | $result[$key] = self::create($item)->appendToEachValue($prefix)->toArray(); |
|
| 520 | } else if (is_object($item)) { |
|
| 521 | $result[$key] = $item; |
|
| 522 | } else { |
|
| 523 | $result[$key] = $prefix . $item; |
|
| 524 | } |
|
| 525 | } |
|
| 526 | ||
| 527 | return self::create($result); |
|
| 528 | } |
|
| 529 | ||
| 530 | /** |
|
| 531 | * Convert an array into a object. |
|
| @@ 2440-2456 (lines=17) @@ | ||
| 2437 | * |
|
| 2438 | * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p> |
|
| 2439 | */ |
|
| 2440 | public function prependToEachValue($suffix) |
|
| 2441 | { |
|
| 2442 | $result = array(); |
|
| 2443 | foreach ($this->array as $key => $item) { |
|
| 2444 | if ($item instanceof self) { |
|
| 2445 | $result[$key] = $item->prependToEachValue($suffix); |
|
| 2446 | } else if (is_array($item)) { |
|
| 2447 | $result[$key] = self::create($item)->prependToEachValue($suffix)->toArray(); |
|
| 2448 | } else if (is_object($item)) { |
|
| 2449 | $result[$key] = $item; |
|
| 2450 | } else { |
|
| 2451 | $result[$key] = $item . $suffix; |
|
| 2452 | } |
|
| 2453 | } |
|
| 2454 | ||
| 2455 | return self::create($result); |
|
| 2456 | } |
|
| 2457 | ||
| 2458 | /** |
|
| 2459 | * Push one or more values onto the end of array at once. |
|