Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 988-1006 (lines=19) @@
985
     * @psalm-return static<TKey,T>
986
     * @psalm-mutation-free
987
     */
988
    public function appendToEachValue($prefix): self
989
    {
990
        // init
991
        $result = [];
992
993
        foreach ($this->getGenerator() as $key => $item) {
994
            if ($item instanceof self) {
995
                $result[$key] = $item->appendToEachValue($prefix);
996
            } elseif (\is_array($item) === true) {
997
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
998
            } elseif (\is_object($item) === true) {
999
                $result[$key] = $item;
1000
            } else {
1001
                $result[$key] = $prefix . $item;
1002
            }
1003
        }
1004
1005
        return self::create($result, $this->iteratorClass, false);
1006
    }
1007
1008
    /**
1009
     * Sort an array in reverse order and maintain index association.
@@ 4184-4211 (lines=28) @@
4181
     * @psalm-return static<TKey,T>
4182
     * @psalm-mutation-free
4183
     */
4184
    public function prependToEachValue($suffix): self
4185
    {
4186
        // init
4187
        $result = [];
4188
4189
        foreach ($this->getGenerator() as $key => $item) {
4190
            if ($item instanceof self) {
4191
                $result[$key] = $item->prependToEachValue($suffix);
4192
            } elseif (\is_array($item) === true) {
4193
                $result[$key] = self::create(
4194
                    $item,
4195
                    $this->iteratorClass,
4196
                    false
4197
                )->prependToEachValue($suffix)
4198
                    ->toArray();
4199
            } elseif (\is_object($item) === true) {
4200
                $result[$key] = $item;
4201
            } else {
4202
                $result[$key] = $item . $suffix;
4203
            }
4204
        }
4205
4206
        return self::create(
4207
            $result,
4208
            $this->iteratorClass,
4209
            false
4210
        );
4211
    }
4212
4213
    /**
4214
     * Return the value of a given key and