Code Duplication    Length = 19-28 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) === true) {
724
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
725
            } elseif (\is_object($item) === true) {
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.
@@ 3171-3198 (lines=28) @@
3168
     * @return static
3169
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3170
     */
3171
    public function prependToEachValue($suffix): self
3172
    {
3173
        // init
3174
        $result = [];
3175
3176
        foreach ($this->getGenerator() as $key => $item) {
3177
            if ($item instanceof self) {
3178
                $result[$key] = $item->prependToEachValue($suffix);
3179
            } elseif (\is_array($item) === true) {
3180
                $result[$key] = self::create(
3181
                    $item,
3182
                    $this->iteratorClass,
3183
                    false
3184
                )->prependToEachValue($suffix)
3185
                    ->toArray();
3186
            } elseif (\is_object($item) === true) {
3187
                $result[$key] = $item;
3188
            } else {
3189
                $result[$key] = $item . $suffix;
3190
            }
3191
        }
3192
3193
        return self::create(
3194
            $result,
3195
            $this->iteratorClass,
3196
            false
3197
        );
3198
    }
3199
3200
    /**
3201
     * Return the value of a given key and