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