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.
@@ 2766-2782 (lines=17) @@
2763
     * @return static
2764
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2765
     */
2766
    public function prependToEachKey($suffix): self
2767
    {
2768
        // init
2769
        $result = [];
2770
2771
        foreach ($this->getGenerator() as $key => $item) {
2772
            if ($item instanceof self) {
2773
                $result[$key] = $item->prependToEachKey($suffix);
2774
            } elseif (\is_array($item)) {
2775
                $result[$key] = self::create(
2776
                    $item,
2777
                    $this->iteratorClass,
2778
                    false
2779
                )->prependToEachKey($suffix)
2780
                 ->toArray();
2781
            } else {
2782
                $result[$key . $suffix] = $item;
2783
            }
2784
        }
2785