Code Duplication    Length = 19-26 lines in 2 locations

src/Arrayy.php 2 locations

@@ 758-776 (lines=19) @@
755
     *
756
     * @psalm-return static<TKey,T>
757
     */
758
    public function appendToEachKey($prefix): self
759
    {
760
        // init
761
        $result = [];
762
763
        foreach ($this->getGenerator() as $key => $item) {
764
            if ($item instanceof self) {
765
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
766
            } elseif (\is_array($item) === true) {
767
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
768
                    ->appendToEachKey($prefix)
769
                    ->toArray();
770
            } else {
771
                $result[$prefix . $key] = $item;
772
            }
773
        }
774
775
        return self::create($result, $this->iteratorClass, false);
776
    }
777
778
    /**
779
     * Add a prefix to each value.
@@ 3578-3603 (lines=26) @@
3575
     *
3576
     * @psalm-return static<TKey,T>
3577
     */
3578
    public function prependToEachKey($suffix): self
3579
    {
3580
        // init
3581
        $result = [];
3582
3583
        foreach ($this->getGenerator() as $key => $item) {
3584
            if ($item instanceof self) {
3585
                $result[$key] = $item->prependToEachKey($suffix);
3586
            } elseif (\is_array($item) === true) {
3587
                $result[$key] = self::create(
3588
                    $item,
3589
                    $this->iteratorClass,
3590
                    false
3591
                )->prependToEachKey($suffix)
3592
                    ->toArray();
3593
            } else {
3594
                $result[$key . $suffix] = $item;
3595
            }
3596
        }
3597
3598
        return self::create(
3599
            $result,
3600
            $this->iteratorClass,
3601
            false
3602
        );
3603
    }
3604
3605
    /**
3606
     * Add a suffix to each value.