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.
@@ 3217-3244 (lines=28) @@
3214
     * @return static
3215
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3216
     */
3217
    public function prependToEachValue($suffix): self
3218
    {
3219
        // init
3220
        $result = [];
3221
3222
        foreach ($this->getGenerator() as $key => $item) {
3223
            if ($item instanceof self) {
3224
                $result[$key] = $item->prependToEachValue($suffix);
3225
            } elseif (\is_array($item) === true) {
3226
                $result[$key] = self::create(
3227
                    $item,
3228
                    $this->iteratorClass,
3229
                    false
3230
                )->prependToEachValue($suffix)
3231
                    ->toArray();
3232
            } elseif (\is_object($item) === true) {
3233
                $result[$key] = $item;
3234
            } else {
3235
                $result[$key] = $item . $suffix;
3236
            }
3237
        }
3238
3239
        return self::create(
3240
            $result,
3241
            $this->iteratorClass,
3242
            false
3243
        );
3244
    }
3245
3246
    /**
3247
     * Return the value of a given key and