Code Duplication    Length = 18-19 lines in 2 locations

src/Arrayy.php 2 locations

@@ 628-646 (lines=19) @@
625
     * @return static
626
     *                <p>(Immutable) Return an Arrayy object, with the prefixed keys.</p>
627
     */
628
    public function appendToEachKey($prefix)
629
    {
630
        // init
631
        $result = [];
632
633
        foreach ($this->getGenerator() as $key => $item) {
634
            if ($item instanceof self) {
635
                $result[$prefix . $key] = $item->appendToEachKey($prefix);
636
            } elseif (\is_array($item)) {
637
                $result[$prefix . $key] = self::create($item, $this->iteratorClass, false)
638
                    ->appendToEachKey($prefix)
639
                    ->toArray();
640
            } else {
641
                $result[$prefix . $key] = $item;
642
            }
643
        }
644
645
        return self::create($result, $this->iteratorClass, false);
646
    }
647
648
    /**
649
     * Add a prefix to each value.
@@ 2582-2599 (lines=18) @@
2579
     * @return static
2580
     *                <p>(Immutable) Return an Arrayy object, with the prepended keys.</p>
2581
     */
2582
    public function prependToEachKey($suffix)
2583
    {
2584
        // init
2585
        $result = [];
2586
2587
        foreach ($this->getGenerator() as $key => $item) {
2588
            if ($item instanceof self) {
2589
                $result[$key] = $item->prependToEachKey($suffix);
2590
            } elseif (\is_array($item)) {
2591
                $result[$key] = self::create($item, $this->iteratorClass, false)->prependToEachKey($suffix)->toArray();
2592
            } else {
2593
                $result[$key . $suffix] = $item;
2594
            }
2595
        }
2596
2597
        return self::create($result, $this->iteratorClass, false);
2598
    }
2599
2600
    /**
2601
     * Add a suffix to each value.
2602
     *