Code Duplication    Length = 10-12 lines in 4 locations

src/Arrayy.php 4 locations

@@ 685-694 (lines=10) @@
682
   *
683
   * @return static <p>(Immutable)</p>
684
   */
685
  public function at(\Closure $closure)
686
  {
687
    $array = $this->array;
688
689
    foreach ($array as $key => $value) {
690
      $closure($value, $key);
691
    }
692
693
    return static::create($array);
694
  }
695
696
  /**
697
   * Returns the average value of the current array.
@@ 1246-1255 (lines=10) @@
1243
   *
1244
   * @return static <p>(Immutable)</p>
1245
   */
1246
  public function each(\Closure $closure)
1247
  {
1248
    $array = $this->array;
1249
1250
    foreach ($array as $key => $value) {
1251
      $array[$key] = $closure($value, $key);
1252
    }
1253
1254
    return static::create($array);
1255
  }
1256
1257
  /**
1258
   * Check if a value is in the current array using a closure.
@@ 1498-1507 (lines=10) @@
1495
   *
1496
   * @return mixed|false <p>Return false if we did not find the value.</p>
1497
   */
1498
  public function find(\Closure $closure)
1499
  {
1500
    foreach ($this->array as $key => $value) {
1501
      if ($closure($value, $key)) {
1502
        return $value;
1503
      }
1504
    }
1505
1506
    return false;
1507
  }
1508
1509
  /**
1510
   * find by ...
@@ 2948-2959 (lines=12) @@
2945
   *
2946
   * @return static <p>(Immutable)</p>
2947
   */
2948
  public function reject(\Closure $closure)
2949
  {
2950
    $filtered = [];
2951
2952
    foreach ($this->array as $key => $value) {
2953
      if (!$closure($value, $key)) {
2954
        $filtered[$key] = $value;
2955
      }
2956
    }
2957
2958
    return static::create($filtered);
2959
  }
2960
2961
  /**
2962
   * Remove a value from the current array (optional using dot-notation).