Code Duplication    Length = 15-16 lines in 5 locations

src/Arrayy.php 5 locations

@@ 2668-2683 (lines=16) @@
2665
     * @psalm-return static<TKey,T>
2666
     * @psalm-mutation-free
2667
     */
2668
    public function firstsKeys(int $number = null): self
2669
    {
2670
        $arrayTmp = $this->keys()->toArray();
2671
2672
        if ($number === null) {
2673
            $array = (array) \array_shift($arrayTmp);
2674
        } else {
2675
            $array = \array_splice($arrayTmp, 0, $number);
2676
        }
2677
2678
        return static::create(
2679
            $array,
2680
            $this->iteratorClass,
2681
            false
2682
        );
2683
    }
2684
2685
    /**
2686
     * Get and remove the first value(s) from the current array.
@@ 4256-4270 (lines=15) @@
4253
     * @psalm-return static<int|TKey,T>
4254
     * @psalm-mutation-free
4255
     */
4256
    public function mergeAppendKeepIndex(array $array = [], bool $recursive = false): self
4257
    {
4258
        if ($recursive === true) {
4259
            $array = $this->getArrayRecursiveHelperArrayy($array);
4260
            $result = \array_replace_recursive($this->toArray(), $array);
4261
        } else {
4262
            $result = \array_replace($this->toArray(), $array);
4263
        }
4264
4265
        return static::create(
4266
            $result,
4267
            $this->iteratorClass,
4268
            false
4269
        );
4270
    }
4271
4272
    /**
4273
     * Merge the new $array into the current array.
@@ 4298-4312 (lines=15) @@
4295
     * @psalm-return static<TKey,T>
4296
     * @psalm-mutation-free
4297
     */
4298
    public function mergeAppendNewIndex(array $array = [], bool $recursive = false): self
4299
    {
4300
        if ($recursive === true) {
4301
            $array = $this->getArrayRecursiveHelperArrayy($array);
4302
            $result = \array_merge_recursive($this->toArray(), $array);
4303
        } else {
4304
            $result = \array_merge($this->toArray(), $array);
4305
        }
4306
4307
        return static::create(
4308
            $result,
4309
            $this->iteratorClass,
4310
            false
4311
        );
4312
    }
4313
4314
    /**
4315
     * Merge the the current array into the $array.
@@ 4339-4353 (lines=15) @@
4336
     * @psalm-return static<TKey,T>
4337
     * @psalm-mutation-free
4338
     */
4339
    public function mergePrependKeepIndex(array $array = [], bool $recursive = false): self
4340
    {
4341
        if ($recursive === true) {
4342
            $array = $this->getArrayRecursiveHelperArrayy($array);
4343
            $result = \array_replace_recursive($array, $this->toArray());
4344
        } else {
4345
            $result = \array_replace($array, $this->toArray());
4346
        }
4347
4348
        return static::create(
4349
            $result,
4350
            $this->iteratorClass,
4351
            false
4352
        );
4353
    }
4354
4355
    /**
4356
     * Merge the current array into the new $array.
@@ 4381-4395 (lines=15) @@
4378
     * @psalm-return static<TKey,T>
4379
     * @psalm-mutation-free
4380
     */
4381
    public function mergePrependNewIndex(array $array = [], bool $recursive = false): self
4382
    {
4383
        if ($recursive === true) {
4384
            $array = $this->getArrayRecursiveHelperArrayy($array);
4385
            $result = \array_merge_recursive($array, $this->toArray());
4386
        } else {
4387
            $result = \array_merge($array, $this->toArray());
4388
        }
4389
4390
        return static::create(
4391
            $result,
4392
            $this->iteratorClass,
4393
            false
4394
        );
4395
    }
4396
4397
    /**
4398
     * @return ArrayyMeta|mixed|static