Code Duplication    Length = 15-16 lines in 5 locations

src/Arrayy.php 5 locations

@@ 2679-2694 (lines=16) @@
2676
     * @psalm-return static<TKey,T>
2677
     * @psalm-mutation-free
2678
     */
2679
    public function firstsKeys(int $number = null): self
2680
    {
2681
        $arrayTmp = $this->keys()->toArray();
2682
2683
        if ($number === null) {
2684
            $array = (array) \array_shift($arrayTmp);
2685
        } else {
2686
            $array = \array_splice($arrayTmp, 0, $number);
2687
        }
2688
2689
        return static::create(
2690
            $array,
2691
            $this->iteratorClass,
2692
            false
2693
        );
2694
    }
2695
2696
    /**
2697
     * Get and remove the first value(s) from the current array.
@@ 4275-4289 (lines=15) @@
4272
     * @psalm-return static<int|TKey,T>
4273
     * @psalm-mutation-free
4274
     */
4275
    public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self
4276
    {
4277
        if ($recursive === true) {
4278
            $array = $this->getArrayRecursiveHelperArrayy($array);
4279
            $result = \array_replace_recursive($this->toArray(), $array);
4280
        } else {
4281
            $result = \array_replace($this->toArray(), $array);
4282
        }
4283
4284
        return static::create(
4285
            $result,
4286
            $this->iteratorClass,
4287
            false
4288
        );
4289
    }
4290
4291
    /**
4292
     * Merge the new $array into the current array.
@@ 4317-4331 (lines=15) @@
4314
     * @psalm-return static<TKey,T>
4315
     * @psalm-mutation-free
4316
     */
4317
    public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self
4318
    {
4319
        if ($recursive === true) {
4320
            $array = $this->getArrayRecursiveHelperArrayy($array);
4321
            $result = \array_merge_recursive($this->toArray(), $array);
4322
        } else {
4323
            $result = \array_merge($this->toArray(), $array);
4324
        }
4325
4326
        return static::create(
4327
            $result,
4328
            $this->iteratorClass,
4329
            false
4330
        );
4331
    }
4332
4333
    /**
4334
     * Merge the the current array into the $array.
@@ 4358-4372 (lines=15) @@
4355
     * @psalm-return static<TKey,T>
4356
     * @psalm-mutation-free
4357
     */
4358
    public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self
4359
    {
4360
        if ($recursive === true) {
4361
            $array = $this->getArrayRecursiveHelperArrayy($array);
4362
            $result = \array_replace_recursive($array, $this->toArray());
4363
        } else {
4364
            $result = \array_replace($array, $this->toArray());
4365
        }
4366
4367
        return static::create(
4368
            $result,
4369
            $this->iteratorClass,
4370
            false
4371
        );
4372
    }
4373
4374
    /**
4375
     * Merge the current array into the new $array.
@@ 4400-4414 (lines=15) @@
4397
     * @psalm-return static<TKey,T>
4398
     * @psalm-mutation-free
4399
     */
4400
    public function mergePrependNewIndex(array $array = [], bool $recursive = false): self
4401
    {
4402
        if ($recursive === true) {
4403
            $array = $this->getArrayRecursiveHelperArrayy($array);
4404
            $result = \array_merge_recursive($array, $this->toArray());
4405
        } else {
4406
            $result = \array_merge($array, $this->toArray());
4407
        }
4408
4409
        return static::create(
4410
            $result,
4411
            $this->iteratorClass,
4412
            false
4413
        );
4414
    }
4415
4416
    /**
4417
     * @return ArrayyMeta|mixed|static