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.
@@ 2895-2911 (lines=17) @@
2892
     * @return static
2893
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2894
     */
2895
    public function prependToEachKey($suffix): self
2896
    {
2897
        // init
2898
        $result = [];
2899
2900
        foreach ($this->getGenerator() as $key => $item) {
2901
            if ($item instanceof self) {
2902
                $result[$key] = $item->prependToEachKey($suffix);
2903
            } elseif (\is_array($item)) {
2904
                $result[$key] = self::create(
2905
                    $item,
2906
                    $this->iteratorClass,
2907
                    false
2908
                )->prependToEachKey($suffix)
2909
                    ->toArray();
2910
            } else {
2911
                $result[$key . $suffix] = $item;
2912
            }
2913
        }
2914