Code Duplication    Length = 16-16 lines in 2 locations

src/Arrayy.php 2 locations

@@ 4378-4393 (lines=16) @@
4375
     * @psalm-return static<TKey,T>
4376
     * @psalm-mutation-free
4377
     */
4378
    public function moveElementToFirstPlace($key): self
4379
    {
4380
        $array = $this->toArray();
4381
4382
        if ($this->offsetExists($key)) {
4383
            $tmpValue = $this->get($key);
4384
            unset($array[$key]);
4385
            $array = [$key => $tmpValue] + $array;
4386
        }
4387
4388
        return static::create(
4389
            $array,
4390
            $this->iteratorClass,
4391
            false
4392
        );
4393
    }
4394
4395
    /**
4396
     * Move an array element to the last place.
@@ 4409-4424 (lines=16) @@
4406
     * @psalm-return static<TKey,T>
4407
     * @psalm-mutation-free
4408
     */
4409
    public function moveElementToLastPlace($key): self
4410
    {
4411
        $array = $this->toArray();
4412
4413
        if ($this->offsetExists($key)) {
4414
            $tmpValue = $this->get($key);
4415
            unset($array[$key]);
4416
            $array += [$key => $tmpValue];
4417
        }
4418
4419
        return static::create(
4420
            $array,
4421
            $this->iteratorClass,
4422
            false
4423
        );
4424
    }
4425
4426
    /**
4427
     * Moves the internal iterator position to the next element and returns this element.