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.
@@ 3154-3174 (lines=21) @@
3151
     * @return static
3152
     *                <p>(Immutable) Return an Arrayy object, with the prepended values.</p>
3153
     */
3154
    public function prependToEachValue($suffix): self
3155
    {
3156
        // init
3157
        $result = [];
3158
3159
        foreach ($this->getGenerator() as $key => $item) {
3160
            if ($item instanceof self) {
3161
                $result[$key] = $item->prependToEachValue($suffix);
3162
            } elseif (\is_array($item)) {
3163
                $result[$key] = self::create(
3164
                    $item,
3165
                    $this->iteratorClass,
3166
                    false
3167
                )->prependToEachValue($suffix)
3168
                    ->toArray();
3169
            } elseif (\is_object($item)) {
3170
                $result[$key] = $item;
3171
            } else {
3172
                $result[$key] = $item . $suffix;
3173
            }
3174
        }
3175
3176
        return self::create(
3177
            $result,