Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

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