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.
@@ 2954-2970 (lines=17) @@
2951
     * @return static
2952
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2953
     */
2954
    public function prependToEachKey($suffix): self
2955
    {
2956
        // init
2957
        $result = [];
2958
2959
        foreach ($this->getGenerator() as $key => $item) {
2960
            if ($item instanceof self) {
2961
                $result[$key] = $item->prependToEachKey($suffix);
2962
            } elseif (\is_array($item)) {
2963
                $result[$key] = self::create(
2964
                    $item,
2965
                    $this->iteratorClass,
2966
                    false
2967
                )->prependToEachKey($suffix)
2968
                    ->toArray();
2969
            } else {
2970
                $result[$key . $suffix] = $item;
2971
            }
2972
        }
2973