Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1049-1067 (lines=19) @@
1046
     * @psalm-return static<TKey,T>
1047
     * @psalm-mutation-free
1048
     */
1049
    public function appendToEachValue($prefix): self
1050
    {
1051
        // init
1052
        $result = [];
1053
1054
        foreach ($this->getGenerator() as $key => $item) {
1055
            if ($item instanceof self) {
1056
                $result[$key] = $item->appendToEachValue($prefix);
1057
            } elseif (\is_array($item) === true) {
1058
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1059
            } elseif (\is_object($item) === true) {
1060
                $result[$key] = $item;
1061
            } else {
1062
                $result[$key] = $prefix . $item;
1063
            }
1064
        }
1065
1066
        return self::create($result, $this->iteratorClass, false);
1067
    }
1068
1069
    /**
1070
     * Sort an array in reverse order and maintain index association.
@@ 4463-4490 (lines=28) @@
4460
     * @psalm-return static<TKey,T>
4461
     * @psalm-mutation-free
4462
     */
4463
    public function prependToEachValue($suffix): self
4464
    {
4465
        // init
4466
        $result = [];
4467
4468
        foreach ($this->getGenerator() as $key => $item) {
4469
            if ($item instanceof self) {
4470
                $result[$key] = $item->prependToEachValue($suffix);
4471
            } elseif (\is_array($item) === true) {
4472
                $result[$key] = self::create(
4473
                    $item,
4474
                    $this->iteratorClass,
4475
                    false
4476
                )->prependToEachValue($suffix)
4477
                    ->toArray();
4478
            } elseif (\is_object($item) === true) {
4479
                $result[$key] = $item;
4480
            } else {
4481
                $result[$key] = $item . $suffix;
4482
            }
4483
        }
4484
4485
        return self::create(
4486
            $result,
4487
            $this->iteratorClass,
4488
            false
4489
        );
4490
    }
4491
4492
    /**
4493
     * Return the value of a given key and