Code Duplication    Length = 15-16 lines in 5 locations

src/Arrayy.php 5 locations

@@ 2779-2794 (lines=16) @@
2776
     * @phpstan-return static<array-key,TKey>
2777
     * @psalm-mutation-free
2778
     */
2779
    public function firstsKeys(int $number = null): self
2780
    {
2781
        $arrayTmp = $this->keys()->toArray();
2782
2783
        if ($number === null) {
2784
            $array = (array) \array_shift($arrayTmp);
2785
        } else {
2786
            $array = \array_splice($arrayTmp, 0, $number);
2787
        }
2788
2789
        return static::create(
2790
            $array,
2791
            $this->iteratorClass,
2792
            false
2793
        );
2794
    }
2795
2796
    /**
2797
     * Get and remove the first value(s) from the current array.
@@ 4405-4419 (lines=15) @@
4402
     * @phpstan-return static<int|TKey,T>
4403
     * @psalm-mutation-free
4404
     */
4405
    public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self
4406
    {
4407
        if ($recursive === true) {
4408
            $array = $this->getArrayRecursiveHelperArrayy($array);
4409
            $result = \array_replace_recursive($this->toArray(), $array);
4410
        } else {
4411
            $result = \array_replace($this->toArray(), $array);
4412
        }
4413
4414
        return static::create(
4415
            $result,
4416
            $this->iteratorClass,
4417
            false
4418
        );
4419
    }
4420
4421
    /**
4422
     * Merge the new $array into the current array.
@@ 4447-4461 (lines=15) @@
4444
     * @phpstan-return static<int,T>
4445
     * @psalm-mutation-free
4446
     */
4447
    public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self
4448
    {
4449
        if ($recursive === true) {
4450
            $array = $this->getArrayRecursiveHelperArrayy($array);
4451
            $result = \array_merge_recursive($this->toArray(), $array);
4452
        } else {
4453
            $result = \array_merge($this->toArray(), $array);
4454
        }
4455
4456
        return static::create(
4457
            $result,
4458
            $this->iteratorClass,
4459
            false
4460
        );
4461
    }
4462
4463
    /**
4464
     * Merge the the current array into the $array.
@@ 4488-4502 (lines=15) @@
4485
     * @phpstan-return static<TKey,T>
4486
     * @psalm-mutation-free
4487
     */
4488
    public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self
4489
    {
4490
        if ($recursive === true) {
4491
            $array = $this->getArrayRecursiveHelperArrayy($array);
4492
            $result = \array_replace_recursive($array, $this->toArray());
4493
        } else {
4494
            $result = \array_replace($array, $this->toArray());
4495
        }
4496
4497
        return static::create(
4498
            $result,
4499
            $this->iteratorClass,
4500
            false
4501
        );
4502
    }
4503
4504
    /**
4505
     * Merge the current array into the new $array.
@@ 4530-4544 (lines=15) @@
4527
     * @phpstan-return static<int,T>
4528
     * @psalm-mutation-free
4529
     */
4530
    public function mergePrependNewIndex(array $array = [], bool $recursive = false): self
4531
    {
4532
        if ($recursive === true) {
4533
            $array = $this->getArrayRecursiveHelperArrayy($array);
4534
            $result = \array_merge_recursive($array, $this->toArray());
4535
        } else {
4536
            $result = \array_merge($array, $this->toArray());
4537
        }
4538
4539
        return static::create(
4540
            $result,
4541
            $this->iteratorClass,
4542
            false
4543
        );
4544
    }
4545
4546
    /**
4547
     * @return ArrayyMeta|mixed|static