Code Duplication    Length = 17-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 687-705 (lines=19) @@
684
     * @return static
685
     *                <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>
686
     */
687
    public function appendToEachKey($prefix): self
688
    {
689
        // init
690
        $result = [];
691
692
        foreach ($this->getGenerator() as $key => $item) {
693
            if ($item instanceof self) {
694
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
695
            } elseif (\is_array($item)) {
696
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
697
                    ->appendToEachKey($prefix)
698
                    ->toArray();
699
            } else {
700
                $result[$prefix . $key] = $item;
701
            }
702
        }
703
704
        return self::create($result, $this->iteratorClass, false);
705
    }
706
707
    /**
708
     * Add a prefix to each value.
@@ 3085-3101 (lines=17) @@
3082
     * @return static
3083
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
3084
     */
3085
    public function prependToEachKey($suffix): self
3086
    {
3087
        // init
3088
        $result = [];
3089
3090
        foreach ($this->getGenerator() as $key => $item) {
3091
            if ($item instanceof self) {
3092
                $result[$key] = $item->prependToEachKey($suffix);
3093
            } elseif (\is_array($item)) {
3094
                $result[$key] = self::create(
3095
                    $item,
3096
                    $this->iteratorClass,
3097
                    false
3098
                )->prependToEachKey($suffix)
3099
                    ->toArray();
3100
            } else {
3101
                $result[$key . $suffix] = $item;
3102
            }
3103
        }
3104