Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

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