Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 691-709 (lines=19) @@
688
     * @return static
689
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
690
     */
691
    public function appendToEachValue($prefix): self
692
    {
693
        // init
694
        $result = [];
695
696
        foreach ($this->getGenerator() as $key => $item) {
697
            if ($item instanceof self) {
698
                $result[$key] = $item->appendToEachValue($prefix);
699
            } elseif (\is_array($item)) {
700
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
701
            } elseif (\is_object($item)) {
702
                $result[$key] = $item;
703
            } else {
704
                $result[$key] = $prefix . $item;
705
            }
706
        }
707
708
        return self::create($result, $this->iteratorClass, false);
709
    }
710
711
    /**
712
     * Sort an array in reverse order and maintain index association.
@@ 2686-2706 (lines=21) @@
2683
     * @return static
2684
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2685
     */
2686
    public function prependToEachValue($suffix): self
2687
    {
2688
        // init
2689
        $result = [];
2690
2691
        foreach ($this->getGenerator() as $key => $item) {
2692
            if ($item instanceof self) {
2693
                $result[$key] = $item->prependToEachValue($suffix);
2694
            } elseif (\is_array($item)) {
2695
                $result[$key] = self::create($item, $this->iteratorClass, false)
2696
                    ->prependToEachValue($suffix)
2697
                    ->toArray();
2698
            } elseif (\is_object($item)) {
2699
                $result[$key] = $item;
2700
            } else {
2701
                $result[$key] = $item . $suffix;
2702
            }
2703
        }
2704
2705
        return self::create($result, $this->iteratorClass, false);
2706
    }
2707
2708
    /**
2709
     * Push one or more values onto the end of array at once.