Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 996-1014 (lines=19) @@
993
     * @psalm-return static<TKey,T>
994
     * @psalm-mutation-free
995
     */
996
    public function appendToEachValue($prefix): self
997
    {
998
        // init
999
        $result = [];
1000
1001
        foreach ($this->getGenerator() as $key => $item) {
1002
            if ($item instanceof self) {
1003
                $result[$key] = $item->appendToEachValue($prefix);
1004
            } elseif (\is_array($item) === true) {
1005
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1006
            } elseif (\is_object($item) === true) {
1007
                $result[$key] = $item;
1008
            } else {
1009
                $result[$key] = $prefix . $item;
1010
            }
1011
        }
1012
1013
        return self::create($result, $this->iteratorClass, false);
1014
    }
1015
1016
    /**
1017
     * Sort an array in reverse order and maintain index association.
@@ 4194-4221 (lines=28) @@
4191
     * @psalm-return static<TKey,T>
4192
     * @psalm-mutation-free
4193
     */
4194
    public function prependToEachValue($suffix): self
4195
    {
4196
        // init
4197
        $result = [];
4198
4199
        foreach ($this->getGenerator() as $key => $item) {
4200
            if ($item instanceof self) {
4201
                $result[$key] = $item->prependToEachValue($suffix);
4202
            } elseif (\is_array($item) === true) {
4203
                $result[$key] = self::create(
4204
                    $item,
4205
                    $this->iteratorClass,
4206
                    false
4207
                )->prependToEachValue($suffix)
4208
                    ->toArray();
4209
            } elseif (\is_object($item) === true) {
4210
                $result[$key] = $item;
4211
            } else {
4212
                $result[$key] = $item . $suffix;
4213
            }
4214
        }
4215
4216
        return self::create(
4217
            $result,
4218
            $this->iteratorClass,
4219
            false
4220
        );
4221
    }
4222
4223
    /**
4224
     * Return the value of a given key and