Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 693-711 (lines=19) @@
690
     * @return static
691
     *                <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>
692
     */
693
    public function appendToEachKey($prefix): self
694
    {
695
        // init
696
        $result = [];
697
698
        foreach ($this->getGenerator() as $key => $item) {
699
            if ($item instanceof self) {
700
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
701
            } elseif (\is_array($item)) {
702
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
703
                    ->appendToEachKey($prefix)
704
                    ->toArray();
705
            } else {
706
                $result[$prefix . $key] = $item;
707
            }
708
        }
709
710
        return self::create($result, $this->iteratorClass, false);
711
    }
712
713
    /**
714
     * Add a prefix to each value.
@@ 2842-2858 (lines=17) @@
2839
     * @return static
2840
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2841
     */
2842
    public function prependToEachKey($suffix): self
2843
    {
2844
        // init
2845
        $result = [];
2846
2847
        foreach ($this->getGenerator() as $key => $item) {
2848
            if ($item instanceof self) {
2849
                $result[$key] = $item->prependToEachKey($suffix);
2850
            } elseif (\is_array($item)) {
2851
                $result[$key] = self::create(
2852
                    $item,
2853
                    $this->iteratorClass,
2854
                    false
2855
                )->prependToEachKey($suffix)
2856
                    ->toArray();
2857
            } else {
2858
                $result[$key . $suffix] = $item;
2859
            }
2860
        }
2861