Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1074-1092 (lines=19) @@
1071
     * @psalm-return static<TKey,T>
1072
     * @psalm-mutation-free
1073
     */
1074
    public function appendToEachValue($prefix): self
1075
    {
1076
        // init
1077
        $result = [];
1078
1079
        foreach ($this->getGenerator() as $key => $item) {
1080
            if ($item instanceof self) {
1081
                $result[$key] = $item->appendToEachValue($prefix);
1082
            } elseif (\is_array($item)) {
1083
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1084
            } elseif (\is_object($item) === true) {
1085
                $result[$key] = $item;
1086
            } else {
1087
                $result[$key] = $prefix . $item;
1088
            }
1089
        }
1090
1091
        return self::create($result, $this->iteratorClass, false);
1092
    }
1093
1094
    /**
1095
     * Sort an array in reverse order and maintain index association.
@@ 4822-4849 (lines=28) @@
4819
     * @psalm-return static<TKey,T>
4820
     * @psalm-mutation-free
4821
     */
4822
    public function prependToEachValue($suffix): self
4823
    {
4824
        // init
4825
        $result = [];
4826
4827
        foreach ($this->getGenerator() as $key => $item) {
4828
            if ($item instanceof self) {
4829
                $result[$key] = $item->prependToEachValue($suffix);
4830
            } elseif (\is_array($item)) {
4831
                $result[$key] = self::create(
4832
                    $item,
4833
                    $this->iteratorClass,
4834
                    false
4835
                )->prependToEachValue($suffix)
4836
                    ->toArray();
4837
            } elseif (\is_object($item) === true) {
4838
                $result[$key] = $item;
4839
            } else {
4840
                $result[$key] = $item . $suffix;
4841
            }
4842
        }
4843
4844
        return self::create(
4845
            $result,
4846
            $this->iteratorClass,
4847
            false
4848
        );
4849
    }
4850
4851
    /**
4852
     * Return the value of a given key and