Code Duplication    Length = 12-17 lines in 3 locations

src/Arrayy.php 3 locations

@@ 2315-2329 (lines=15) @@
2312
     * @phpstan-return static<TKey,T>
2313
     * @psalm-mutation-free
2314
     */
2315
    public function each(\Closure $closure): self
2316
    {
2317
        // init
2318
        $array = [];
2319
2320
        foreach ($this->getGenerator() as $key => $value) {
2321
            $array[$key] = $closure($value, $key);
2322
        }
2323
2324
        return static::create(
2325
            $array,
2326
            $this->iteratorClass,
2327
            false
2328
        );
2329
    }
2330
2331
    /**
2332
     * Sets the internal iterator to the last element in the array and returns this element.
@@ 5316-5327 (lines=12) @@
5313
     * @phpstan-return static<TKey,T>
5314
     * @psalm-mutation-free
5315
     */
5316
    public function reduce($callable, $initial = []): self
5317
    {
5318
        foreach ($this->getGenerator() as $key => $value) {
5319
            $initial = $callable($initial, $value, $key);
5320
        }
5321
5322
        return static::create(
5323
            $initial,
5324
            $this->iteratorClass,
5325
            false
5326
        );
5327
    }
5328
5329
    /**
5330
     * @param bool $unique
@@ 5402-5418 (lines=17) @@
5399
     * @phpstan-return static<TKey,T>
5400
     * @psalm-mutation-free
5401
     */
5402
    public function reject(\Closure $closure): self
5403
    {
5404
        // init
5405
        $filtered = [];
5406
5407
        foreach ($this->getGenerator() as $key => $value) {
5408
            if (!$closure($value, $key)) {
5409
                $filtered[$key] = $value;
5410
            }
5411
        }
5412
5413
        return static::create(
5414
            $filtered,
5415
            $this->iteratorClass,
5416
            false
5417
        );
5418
    }
5419
5420
    /**
5421
     * Remove a value from the current array (optional using dot-notation).