Code Duplication    Length = 7-10 lines in 3 locations

src/Arrayy.php 3 locations

@@ 2346-2352 (lines=7) @@
2343
                }
2344
            };
2345
        } else {
2346
            $generator = function () use ($closure) {
2347
                foreach ($this->getGenerator() as $key => $value) {
2348
                    if ($closure($value) === true) {
2349
                        yield $key => $value;
2350
                    }
2351
                }
2352
            };
2353
        }
2354
2355
        return static::create(
@@ 2480-2489 (lines=10) @@
2477
     * @return false|mixed
2478
     *                     <p>Return false if we did not find the value.</p>
2479
     */
2480
    public function find(\Closure $closure)
2481
    {
2482
        foreach ($this->getGenerator() as $key => $value) {
2483
            if ($closure($value, $key)) {
2484
                return $value;
2485
            }
2486
        }
2487
2488
        return false;
2489
    }
2490
2491
    /**
2492
     * find by ...
@@ 6653-6662 (lines=10) @@
6650
     * @return bool
6651
     *              <p>TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.</p>
6652
     */
6653
    public function validate(\Closure $closure): bool
6654
    {
6655
        foreach ($this->getGenerator() as $key => $value) {
6656
            if (!$closure($value, $key)) {
6657
                return false;
6658
            }
6659
        }
6660
6661
        return true;
6662
    }
6663
6664
    /**
6665
     * Get all values from a array.