Code Duplication    Length = 19-21 lines in 2 locations

src/Arrayy.php 2 locations

@@ 715-733 (lines=19) @@
712
     * @return static
713
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
714
     */
715
    public function appendToEachValue($prefix): self
716
    {
717
        // init
718
        $result = [];
719
720
        foreach ($this->getGenerator() as $key => $item) {
721
            if ($item instanceof self) {
722
                $result[$key] = $item->appendToEachValue($prefix);
723
            } elseif (\is_array($item)) {
724
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
725
            } elseif (\is_object($item)) {
726
                $result[$key] = $item;
727
            } else {
728
                $result[$key] = $prefix . $item;
729
            }
730
        }
731
732
        return self::create($result, $this->iteratorClass, false);
733
    }
734
735
    /**
736
     * Sort an array in reverse order and maintain index association.
@@ 3059-3079 (lines=21) @@
3056
     * @return static
3057
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3058
     */
3059
    public function prependToEachValue($suffix): self
3060
    {
3061
        // init
3062
        $result = [];
3063
3064
        foreach ($this->getGenerator() as $key => $item) {
3065
            if ($item instanceof self) {
3066
                $result[$key] = $item->prependToEachValue($suffix);
3067
            } elseif (\is_array($item)) {
3068
                $result[$key] = self::create(
3069
                    $item,
3070
                    $this->iteratorClass,
3071
                    false
3072
                )->prependToEachValue($suffix)
3073
                    ->toArray();
3074
            } elseif (\is_object($item)) {
3075
                $result[$key] = $item;
3076
            } else {
3077
                $result[$key] = $item . $suffix;
3078
            }
3079
        }
3080
3081
        return self::create(
3082
            $result,