Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 723-741 (lines=19) @@
720
     * @return static
721
     *                <p>(Immutable) Return an Arrayy object, with the prefixed values.</p>
722
     */
723
    public function appendToEachValue($prefix): self
724
    {
725
        // init
726
        $result = [];
727
728
        foreach ($this->getGenerator() as $key => $item) {
729
            if ($item instanceof self) {
730
                $result[$key] = $item->appendToEachValue($prefix);
731
            } elseif (\is_array($item) === true) {
732
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
733
            } elseif (\is_object($item) === true) {
734
                $result[$key] = $item;
735
            } else {
736
                $result[$key] = $prefix . $item;
737
            }
738
        }
739
740
        return self::create($result, $this->iteratorClass, false);
741
    }
742
743
    /**
744
     * Sort an array in reverse order and maintain index association.
@@ 3179-3206 (lines=28) @@
3176
     * @return static
3177
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3178
     */
3179
    public function prependToEachValue($suffix): self
3180
    {
3181
        // init
3182
        $result = [];
3183
3184
        foreach ($this->getGenerator() as $key => $item) {
3185
            if ($item instanceof self) {
3186
                $result[$key] = $item->prependToEachValue($suffix);
3187
            } elseif (\is_array($item) === true) {
3188
                $result[$key] = self::create(
3189
                    $item,
3190
                    $this->iteratorClass,
3191
                    false
3192
                )->prependToEachValue($suffix)
3193
                    ->toArray();
3194
            } elseif (\is_object($item) === true) {
3195
                $result[$key] = $item;
3196
            } else {
3197
                $result[$key] = $item . $suffix;
3198
            }
3199
        }
3200
3201
        return self::create(
3202
            $result,
3203
            $this->iteratorClass,
3204
            false
3205
        );
3206
    }
3207
3208
    /**
3209
     * Return the value of a given key and