Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 664-682 (lines=19) @@
661
     * @return static
662
     *                <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>
663
     */
664
    public function appendToEachKey($prefix): self
665
    {
666
        // init
667
        $result = [];
668
669
        foreach ($this->getGenerator() as $key => $item) {
670
            if ($item instanceof self) {
671
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
672
            } elseif (\is_array($item)) {
673
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
674
                    ->appendToEachKey($prefix)
675
                    ->toArray();
676
            } else {
677
                $result[$prefix . $key] = $item;
678
            }
679
        }
680
681
        return self::create($result, $this->iteratorClass, false);
682
    }
683
684
    /**
685
     * Add a prefix to each value.
@@ 2661-2677 (lines=17) @@
2658
     * @return static
2659
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2660
     */
2661
    public function prependToEachKey($suffix): self
2662
    {
2663
        // init
2664
        $result = [];
2665
2666
        foreach ($this->getGenerator() as $key => $item) {
2667
            if ($item instanceof self) {
2668
                $result[$key] = $item->prependToEachKey($suffix);
2669
            } elseif (\is_array($item)) {
2670
                $result[$key] = self::create($item, $this->iteratorClass, false)->prependToEachKey($suffix)->toArray();
2671
            } else {
2672
                $result[$key . $suffix] = $item;
2673
            }
2674
        }
2675
2676
        return self::create($result, $this->iteratorClass, false);
2677
    }
2678
2679
    /**
2680
     * Add a suffix to each value.