Code Duplication    Length = 15-16 lines in 5 locations

src/Arrayy.php 5 locations

@@ 2755-2770 (lines=16) @@
2752
     * @phpstan-return static<TKey,T>
2753
     * @psalm-mutation-free
2754
     */
2755
    public function firstsKeys(int $number = null): self
2756
    {
2757
        $arrayTmp = $this->keys()->toArray();
2758
2759
        if ($number === null) {
2760
            $array = (array) \array_shift($arrayTmp);
2761
        } else {
2762
            $array = \array_splice($arrayTmp, 0, $number);
2763
        }
2764
2765
        return static::create(
2766
            $array,
2767
            $this->iteratorClass,
2768
            false
2769
        );
2770
    }
2771
2772
    /**
2773
     * Get and remove the first value(s) from the current array.
@@ 4366-4380 (lines=15) @@
4363
     * @phpstan-return static<int|TKey,T>
4364
     * @psalm-mutation-free
4365
     */
4366
    public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self
4367
    {
4368
        if ($recursive === true) {
4369
            $array = $this->getArrayRecursiveHelperArrayy($array);
4370
            $result = \array_replace_recursive($this->toArray(), $array);
4371
        } else {
4372
            $result = \array_replace($this->toArray(), $array);
4373
        }
4374
4375
        return static::create(
4376
            $result,
4377
            $this->iteratorClass,
4378
            false
4379
        );
4380
    }
4381
4382
    /**
4383
     * Merge the new $array into the current array.
@@ 4408-4422 (lines=15) @@
4405
     * @phpstan-return static<int,T>
4406
     * @psalm-mutation-free
4407
     */
4408
    public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self
4409
    {
4410
        if ($recursive === true) {
4411
            $array = $this->getArrayRecursiveHelperArrayy($array);
4412
            $result = \array_merge_recursive($this->toArray(), $array);
4413
        } else {
4414
            $result = \array_merge($this->toArray(), $array);
4415
        }
4416
4417
        return static::create(
4418
            $result,
4419
            $this->iteratorClass,
4420
            false
4421
        );
4422
    }
4423
4424
    /**
4425
     * Merge the the current array into the $array.
@@ 4449-4463 (lines=15) @@
4446
     * @phpstan-return static<TKey,T>
4447
     * @psalm-mutation-free
4448
     */
4449
    public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self
4450
    {
4451
        if ($recursive === true) {
4452
            $array = $this->getArrayRecursiveHelperArrayy($array);
4453
            $result = \array_replace_recursive($array, $this->toArray());
4454
        } else {
4455
            $result = \array_replace($array, $this->toArray());
4456
        }
4457
4458
        return static::create(
4459
            $result,
4460
            $this->iteratorClass,
4461
            false
4462
        );
4463
    }
4464
4465
    /**
4466
     * Merge the current array into the new $array.
@@ 4491-4505 (lines=15) @@
4488
     * @phpstan-return static<int,T>
4489
     * @psalm-mutation-free
4490
     */
4491
    public function mergePrependNewIndex(array $array = [], bool $recursive = false): self
4492
    {
4493
        if ($recursive === true) {
4494
            $array = $this->getArrayRecursiveHelperArrayy($array);
4495
            $result = \array_merge_recursive($array, $this->toArray());
4496
        } else {
4497
            $result = \array_merge($array, $this->toArray());
4498
        }
4499
4500
        return static::create(
4501
            $result,
4502
            $this->iteratorClass,
4503
            false
4504
        );
4505
    }
4506
4507
    /**
4508
     * @return ArrayyMeta|mixed|static