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.
@@ 4367-4394 (lines=28) @@
4364
     * @psalm-return static<TKey,T>
4365
     * @psalm-mutation-free
4366
     */
4367
    public function prependToEachValue($suffix): self
4368
    {
4369
        // init
4370
        $result = [];
4371
4372
        foreach ($this->getGenerator() as $key => $item) {
4373
            if ($item instanceof self) {
4374
                $result[$key] = $item->prependToEachValue($suffix);
4375
            } elseif (\is_array($item) === true) {
4376
                $result[$key] = self::create(
4377
                    $item,
4378
                    $this->iteratorClass,
4379
                    false
4380
                )->prependToEachValue($suffix)
4381
                    ->toArray();
4382
            } elseif (\is_object($item) === true) {
4383
                $result[$key] = $item;
4384
            } else {
4385
                $result[$key] = $item . $suffix;
4386
            }
4387
        }
4388
4389
        return self::create(
4390
            $result,
4391
            $this->iteratorClass,
4392
            false
4393
        );
4394
    }
4395
4396
    /**
4397
     * Return the value of a given key and