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.
@@ 2879-2895 (lines=17) @@
2876
     * @return static
2877
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2878
     */
2879
    public function prependToEachKey($suffix): self
2880
    {
2881
        // init
2882
        $result = [];
2883
2884
        foreach ($this->getGenerator() as $key => $item) {
2885
            if ($item instanceof self) {
2886
                $result[$key] = $item->prependToEachKey($suffix);
2887
            } elseif (\is_array($item)) {
2888
                $result[$key] = self::create(
2889
                    $item,
2890
                    $this->iteratorClass,
2891
                    false
2892
                )->prependToEachKey($suffix)
2893
                    ->toArray();
2894
            } else {
2895
                $result[$key . $suffix] = $item;
2896
            }
2897
        }
2898