Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 658-676 (lines=19) @@
655
     * @return static
656
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
657
     */
658
    public function appendToEachValue($prefix)
659
    {
660
        // init
661
        $result = [];
662
663
        foreach ($this->getGenerator() as $key => $item) {
664
            if ($item instanceof self) {
665
                $result[$key] = $item->appendToEachValue($prefix);
666
            } elseif (\is_array($item)) {
667
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
668
            } elseif (\is_object($item)) {
669
                $result[$key] = $item;
670
            } else {
671
                $result[$key] = $prefix . $item;
672
            }
673
        }
674
675
        return self::create($result, $this->iteratorClass, false);
676
    }
677
678
    /**
679
     * Convert an array into a object.
@@ 3016-3036 (lines=21) @@
3013
     * @return static
3014
     *                 <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3015
     */
3016
    public function prependToEachValue($suffix)
3017
    {
3018
        // init
3019
        $result = [];
3020
3021
        foreach ($this->getGenerator() as $key => $item) {
3022
            if ($item instanceof self) {
3023
                $result[$key] = $item->prependToEachValue($suffix);
3024
            } elseif (\is_array($item)) {
3025
                $result[$key] = self::create($item, $this->iteratorClass, false)
3026
                                    ->prependToEachValue($suffix)
3027
                                    ->toArray();
3028
            } elseif (\is_object($item)) {
3029
                $result[$key] = $item;
3030
            } else {
3031
                $result[$key] = $item . $suffix;
3032
            }
3033
        }
3034
3035
        return self::create($result, $this->iteratorClass, false);
3036
    }
3037
3038
    /**
3039
     * Push one or more values onto the end of array at once.