Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 656-674 (lines=19) @@
653
     * @return static
654
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
655
     */
656
    public function appendToEachValue($prefix)
657
    {
658
        // init
659
        $result = [];
660
661
        foreach ($this->getGenerator() as $key => $item) {
662
            if ($item instanceof self) {
663
                $result[$key] = $item->appendToEachValue($prefix);
664
            } elseif (\is_array($item)) {
665
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
666
            } elseif (\is_object($item)) {
667
                $result[$key] = $item;
668
            } else {
669
                $result[$key] = $prefix . $item;
670
            }
671
        }
672
673
        return self::create($result, $this->iteratorClass, false);
674
    }
675
676
    /**
677
     * Sort an array in reverse order and maintain index association.
@@ 2608-2628 (lines=21) @@
2605
     * @return static
2606
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2607
     */
2608
    public function prependToEachValue($suffix)
2609
    {
2610
        // init
2611
        $result = [];
2612
2613
        foreach ($this->getGenerator() as $key => $item) {
2614
            if ($item instanceof self) {
2615
                $result[$key] = $item->prependToEachValue($suffix);
2616
            } elseif (\is_array($item)) {
2617
                $result[$key] = self::create($item, $this->iteratorClass, false)
2618
                    ->prependToEachValue($suffix)
2619
                    ->toArray();
2620
            } elseif (\is_object($item)) {
2621
                $result[$key] = $item;
2622
            } else {
2623
                $result[$key] = $item . $suffix;
2624
            }
2625
        }
2626
2627
        return self::create($result, $this->iteratorClass, false);
2628
    }
2629
2630
    /**
2631
     * Push one or more values onto the end of array at once.