Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 696-714 (lines=19) @@
693
     * @return static
694
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
695
     */
696
    public function appendToEachValue($prefix): self
697
    {
698
        // init
699
        $result = [];
700
701
        foreach ($this->getGenerator() as $key => $item) {
702
            if ($item instanceof self) {
703
                $result[$key] = $item->appendToEachValue($prefix);
704
            } elseif (\is_array($item)) {
705
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
706
            } elseif (\is_object($item)) {
707
                $result[$key] = $item;
708
            } else {
709
                $result[$key] = $prefix . $item;
710
            }
711
        }
712
713
        return self::create($result, $this->iteratorClass, false);
714
    }
715
716
    /**
717
     * Sort an array in reverse order and maintain index association.
@@ 2798-2818 (lines=21) @@
2795
     * @return static
2796
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
2797
     */
2798
    public function prependToEachValue($suffix): self
2799
    {
2800
        // init
2801
        $result = [];
2802
2803
        foreach ($this->getGenerator() as $key => $item) {
2804
            if ($item instanceof self) {
2805
                $result[$key] = $item->prependToEachValue($suffix);
2806
            } elseif (\is_array($item)) {
2807
                $result[$key] = self::create(
2808
                    $item,
2809
                    $this->iteratorClass,
2810
                    false
2811
                )->prependToEachValue($suffix)
2812
                    ->toArray();
2813
            } elseif (\is_object($item)) {
2814
                $result[$key] = $item;
2815
            } else {
2816
                $result[$key] = $item . $suffix;
2817
            }
2818
        }
2819
2820
        return self::create(
2821
            $result,