Code Duplication    Length = 10-12 lines in 4 locations

src/Arrayy.php 4 locations

@@ 644-653 (lines=10) @@
641
   *
642
   * @return static <p>(Immutable)</p>
643
   */
644
  public function at(\Closure $closure)
645
  {
646
    $array = $this->array;
647
648
    foreach ($array as $key => $value) {
649
      $closure($value, $key);
650
    }
651
652
    return static::create($array);
653
  }
654
655
  /**
656
   * Returns the average value of the current array.
@@ 1205-1214 (lines=10) @@
1202
   *
1203
   * @return static <p>(Immutable)</p>
1204
   */
1205
  public function each(\Closure $closure)
1206
  {
1207
    $array = $this->array;
1208
1209
    foreach ($array as $key => $value) {
1210
      $array[$key] = $closure($value, $key);
1211
    }
1212
1213
    return static::create($array);
1214
  }
1215
1216
  /**
1217
   * Check if a value is in the current array using a closure.
@@ 1457-1466 (lines=10) @@
1454
   *
1455
   * @return mixed|false <p>Return false if we did not find the value.</p>
1456
   */
1457
  public function find(\Closure $closure)
1458
  {
1459
    foreach ($this->array as $key => $value) {
1460
      if ($closure($value, $key)) {
1461
        return $value;
1462
      }
1463
    }
1464
1465
    return false;
1466
  }
1467
1468
  /**
1469
   * find by ...
@@ 2900-2911 (lines=12) @@
2897
   *
2898
   * @return static <p>(Immutable)</p>
2899
   */
2900
  public function reject(\Closure $closure)
2901
  {
2902
    $filtered = [];
2903
2904
    foreach ($this->array as $key => $value) {
2905
      if (!$closure($value, $key)) {
2906
        $filtered[$key] = $value;
2907
      }
2908
    }
2909
2910
    return static::create($filtered);
2911
  }
2912
2913
  /**
2914
   * Remove a value from the current array (optional using dot-notation).