Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1005-1023 (lines=19) @@
1002
     * @psalm-return static<TKey,T>
1003
     * @psalm-mutation-free
1004
     */
1005
    public function appendToEachValue($prefix): self
1006
    {
1007
        // init
1008
        $result = [];
1009
1010
        foreach ($this->getGenerator() as $key => $item) {
1011
            if ($item instanceof self) {
1012
                $result[$key] = $item->appendToEachValue($prefix);
1013
            } elseif (\is_array($item) === true) {
1014
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1015
            } elseif (\is_object($item) === true) {
1016
                $result[$key] = $item;
1017
            } else {
1018
                $result[$key] = $prefix . $item;
1019
            }
1020
        }
1021
1022
        return self::create($result, $this->iteratorClass, false);
1023
    }
1024
1025
    /**
1026
     * Sort an array in reverse order and maintain index association.
@@ 4357-4384 (lines=28) @@
4354
     * @psalm-return static<TKey,T>
4355
     * @psalm-mutation-free
4356
     */
4357
    public function prependToEachValue($suffix): self
4358
    {
4359
        // init
4360
        $result = [];
4361
4362
        foreach ($this->getGenerator() as $key => $item) {
4363
            if ($item instanceof self) {
4364
                $result[$key] = $item->prependToEachValue($suffix);
4365
            } elseif (\is_array($item) === true) {
4366
                $result[$key] = self::create(
4367
                    $item,
4368
                    $this->iteratorClass,
4369
                    false
4370
                )->prependToEachValue($suffix)
4371
                    ->toArray();
4372
            } elseif (\is_object($item) === true) {
4373
                $result[$key] = $item;
4374
            } else {
4375
                $result[$key] = $item . $suffix;
4376
            }
4377
        }
4378
4379
        return self::create(
4380
            $result,
4381
            $this->iteratorClass,
4382
            false
4383
        );
4384
    }
4385
4386
    /**
4387
     * Return the value of a given key and