Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 627-645 (lines=19) @@
624
   *
625
   * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
626
   */
627
  public function appendToEachValue($prefix)
628
  {
629
    // init
630
    $result = [];
631
632
    foreach ($this->getGenerator() as $key => $item) {
633
      if ($item instanceof self) {
634
        $result[$key] = $item->appendToEachValue($prefix);
635
      } elseif (\is_array($item)) {
636
        $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
637
      } elseif (\is_object($item)) {
638
        $result[$key] = $item;
639
      } else {
640
        $result[$key] = $prefix . $item;
641
      }
642
    }
643
644
    return self::create($result, $this->iteratorClass, false);
645
  }
646
647
  /**
648
   * Convert an array into a object.
@@ 2915-2935 (lines=21) @@
2912
   *
2913
   * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2914
   */
2915
  public function prependToEachValue($suffix)
2916
  {
2917
    // init
2918
    $result = [];
2919
2920
    foreach ($this->getGenerator() as $key => $item) {
2921
      if ($item instanceof self) {
2922
        $result[$key] = $item->prependToEachValue($suffix);
2923
      } elseif (\is_array($item)) {
2924
        $result[$key] = self::create($item, $this->iteratorClass, false)
2925
                            ->prependToEachValue($suffix)
2926
                            ->toArray();
2927
      } elseif (\is_object($item)) {
2928
        $result[$key] = $item;
2929
      } else {
2930
        $result[$key] = $item . $suffix;
2931
      }
2932
    }
2933
2934
    return self::create($result, $this->iteratorClass, false);
2935
  }
2936
2937
  /**
2938
   * Push one or more values onto the end of array at once.