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.
@@ 4352-4379 (lines=28) @@
4349
     * @psalm-return static<TKey,T>
4350
     * @psalm-mutation-free
4351
     */
4352
    public function prependToEachValue($suffix): self
4353
    {
4354
        // init
4355
        $result = [];
4356
4357
        foreach ($this->getGenerator() as $key => $item) {
4358
            if ($item instanceof self) {
4359
                $result[$key] = $item->prependToEachValue($suffix);
4360
            } elseif (\is_array($item) === true) {
4361
                $result[$key] = self::create(
4362
                    $item,
4363
                    $this->iteratorClass,
4364
                    false
4365
                )->prependToEachValue($suffix)
4366
                    ->toArray();
4367
            } elseif (\is_object($item) === true) {
4368
                $result[$key] = $item;
4369
            } else {
4370
                $result[$key] = $item . $suffix;
4371
            }
4372
        }
4373
4374
        return self::create(
4375
            $result,
4376
            $this->iteratorClass,
4377
            false
4378
        );
4379
    }
4380
4381
    /**
4382
     * Return the value of a given key and