Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1066-1084 (lines=19) @@
1063
     * @psalm-return static<TKey,T>
1064
     * @psalm-mutation-free
1065
     */
1066
    public function appendToEachValue($prefix): self
1067
    {
1068
        // init
1069
        $result = [];
1070
1071
        foreach ($this->getGenerator() as $key => $item) {
1072
            if ($item instanceof self) {
1073
                $result[$key] = $item->appendToEachValue($prefix);
1074
            } elseif (\is_array($item)) {
1075
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1076
            } elseif (\is_object($item) === true) {
1077
                $result[$key] = $item;
1078
            } else {
1079
                $result[$key] = $prefix . $item;
1080
            }
1081
        }
1082
1083
        return self::create($result, $this->iteratorClass, false);
1084
    }
1085
1086
    /**
1087
     * Sort an array in reverse order and maintain index association.
@@ 4687-4714 (lines=28) @@
4684
     * @psalm-return static<TKey,T>
4685
     * @psalm-mutation-free
4686
     */
4687
    public function prependToEachValue($suffix): self
4688
    {
4689
        // init
4690
        $result = [];
4691
4692
        foreach ($this->getGenerator() as $key => $item) {
4693
            if ($item instanceof self) {
4694
                $result[$key] = $item->prependToEachValue($suffix);
4695
            } elseif (\is_array($item)) {
4696
                $result[$key] = self::create(
4697
                    $item,
4698
                    $this->iteratorClass,
4699
                    false
4700
                )->prependToEachValue($suffix)
4701
                    ->toArray();
4702
            } elseif (\is_object($item) === true) {
4703
                $result[$key] = $item;
4704
            } else {
4705
                $result[$key] = $item . $suffix;
4706
            }
4707
        }
4708
4709
        return self::create(
4710
            $result,
4711
            $this->iteratorClass,
4712
            false
4713
        );
4714
    }
4715
4716
    /**
4717
     * Return the value of a given key and