Code Duplication    Length = 12-17 lines in 3 locations

src/Arrayy.php 3 locations

@@ 2313-2327 (lines=15) @@
2310
     * @phpstan-return static<TKey,T>
2311
     * @psalm-mutation-free
2312
     */
2313
    public function each(\Closure $closure): self
2314
    {
2315
        // init
2316
        $array = [];
2317
2318
        foreach ($this->getGenerator() as $key => $value) {
2319
            $array[$key] = $closure($value, $key);
2320
        }
2321
2322
        return static::create(
2323
            $array,
2324
            $this->iteratorClass,
2325
            false
2326
        );
2327
    }
2328
2329
    /**
2330
     * Sets the internal iterator to the last element in the array and returns this element.
@@ 5323-5334 (lines=12) @@
5320
     * @phpstan-return static<TKey,T2>
5321
     * @psalm-mutation-free
5322
     */
5323
    public function reduce($callable, $initial = []): self
5324
    {
5325
        foreach ($this->getGenerator() as $key => $value) {
5326
            $initial = $callable($initial, $value, $key);
5327
        }
5328
5329
        return static::create(
5330
            $initial,
5331
            $this->iteratorClass,
5332
            false
5333
        );
5334
    }
5335
5336
    /**
5337
     * @param bool $unique
@@ 5409-5425 (lines=17) @@
5406
     * @phpstan-return static<TKey,T>
5407
     * @psalm-mutation-free
5408
     */
5409
    public function reject(\Closure $closure): self
5410
    {
5411
        // init
5412
        $filtered = [];
5413
5414
        foreach ($this->getGenerator() as $key => $value) {
5415
            if (!$closure($value, $key)) {
5416
                $filtered[$key] = $value;
5417
            }
5418
        }
5419
5420
        return static::create(
5421
            $filtered,
5422
            $this->iteratorClass,
5423
            false
5424
        );
5425
    }
5426
5427
    /**
5428
     * Remove a value from the current array (optional using dot-notation).