Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 630-648 (lines=19) @@
627
   *
628
   * @return static <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
629
   */
630
  public function appendToEachValue($prefix)
631
  {
632
    // init
633
    $result = [];
634
635
    foreach ($this->getGenerator() as $key => $item) {
636
      if ($item instanceof self) {
637
        $result[$key] = $item->appendToEachValue($prefix);
638
      } elseif (\is_array($item)) {
639
        $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
640
      } elseif (\is_object($item)) {
641
        $result[$key] = $item;
642
      } else {
643
        $result[$key] = $prefix . $item;
644
      }
645
    }
646
647
    return self::create($result, $this->iteratorClass, false);
648
  }
649
650
  /**
651
   * Convert an array into a object.
@@ 2891-2911 (lines=21) @@
2888
   *
2889
   * @return static <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2890
   */
2891
  public function prependToEachValue($suffix)
2892
  {
2893
    // init
2894
    $result = [];
2895
2896
    foreach ($this->getGenerator() as $key => $item) {
2897
      if ($item instanceof self) {
2898
        $result[$key] = $item->prependToEachValue($suffix);
2899
      } elseif (\is_array($item)) {
2900
        $result[$key] = self::create($item, $this->iteratorClass, false)
2901
                            ->prependToEachValue($suffix)
2902
                            ->toArray();
2903
      } elseif (\is_object($item)) {
2904
        $result[$key] = $item;
2905
      } else {
2906
        $result[$key] = $item . $suffix;
2907
      }
2908
    }
2909
2910
    return self::create($result, $this->iteratorClass, false);
2911
  }
2912
2913
  /**
2914
   * Push one or more values onto the end of array at once.