Code Duplication    Length = 16-16 lines in 2 locations

src/Arrayy.php 2 locations

@@ 4529-4544 (lines=16) @@
4526
     * @psalm-return static<TKey,T>
4527
     * @psalm-mutation-free
4528
     */
4529
    public function moveElementToFirstPlace($key): self
4530
    {
4531
        $array = $this->toArray();
4532
4533
        if ($this->offsetExists($key)) {
4534
            $tmpValue = $this->get($key);
4535
            unset($array[$key]);
4536
            $array = [$key => $tmpValue] + $array;
4537
        }
4538
4539
        return static::create(
4540
            $array,
4541
            $this->iteratorClass,
4542
            false
4543
        );
4544
    }
4545
4546
    /**
4547
     * Move an array element to the last place.
@@ 4560-4575 (lines=16) @@
4557
     * @psalm-return static<TKey,T>
4558
     * @psalm-mutation-free
4559
     */
4560
    public function moveElementToLastPlace($key): self
4561
    {
4562
        $array = $this->toArray();
4563
4564
        if ($this->offsetExists($key)) {
4565
            $tmpValue = $this->get($key);
4566
            unset($array[$key]);
4567
            $array += [$key => $tmpValue];
4568
        }
4569
4570
        return static::create(
4571
            $array,
4572
            $this->iteratorClass,
4573
            false
4574
        );
4575
    }
4576
4577
    /**
4578
     * Moves the internal iterator position to the next element and returns this element.