Code Duplication    Length = 15-16 lines in 2 locations

src/Arrayy.php 2 locations

@@ 513-527 (lines=15) @@
510
   *
511
   * @return static <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>
512
   */
513
  public function appendToEachKey($prefix)
514
  {
515
    $result = [];
516
    foreach ($this->array as $key => $item) {
517
      if ($item instanceof self) {
518
        $result[$prefix . $key] = $item->appendToEachKey($prefix);
519
      } elseif (\is_array($item)) {
520
        $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray();
521
      } else {
522
        $result[$prefix . $key] = $item;
523
      }
524
    }
525
526
    return self::create($result);
527
  }
528
529
  /**
530
   * Add a prefix to each value.
@@ 2655-2670 (lines=16) @@
2652
   *
2653
   * @return static <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2654
   */
2655
  public function prependToEachKey($suffix)
2656
  {
2657
    $result = [];
2658
    foreach ($this->array as $key => $item) {
2659
      if ($item instanceof self) {
2660
        $result[$key] = $item->prependToEachKey($suffix);
2661
      } elseif (\is_array($item)) {
2662
        $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray();
2663
      } else {
2664
        $result[$key . $suffix] = $item;
2665
      }
2666
2667
    }
2668
2669
    return self::create($result);
2670
  }
2671
2672
  /**
2673
   * Add a suffix to each value.