Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1059-1077 (lines=19) @@
1056
     * @psalm-return static<TKey,T>
1057
     * @psalm-mutation-free
1058
     */
1059
    public function appendToEachValue($prefix): self
1060
    {
1061
        // init
1062
        $result = [];
1063
1064
        foreach ($this->getGenerator() as $key => $item) {
1065
            if ($item instanceof self) {
1066
                $result[$key] = $item->appendToEachValue($prefix);
1067
            } elseif (\is_array($item)) {
1068
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1069
            } elseif (\is_object($item) === true) {
1070
                $result[$key] = $item;
1071
            } else {
1072
                $result[$key] = $prefix . $item;
1073
            }
1074
        }
1075
1076
        return self::create($result, $this->iteratorClass, false);
1077
    }
1078
1079
    /**
1080
     * Sort an array in reverse order and maintain index association.
@@ 4839-4866 (lines=28) @@
4836
     * @psalm-return static<TKey,T>
4837
     * @psalm-mutation-free
4838
     */
4839
    public function prependToEachValue($suffix): self
4840
    {
4841
        // init
4842
        $result = [];
4843
4844
        foreach ($this->getGenerator() as $key => $item) {
4845
            if ($item instanceof self) {
4846
                $result[$key] = $item->prependToEachValue($suffix);
4847
            } elseif (\is_array($item)) {
4848
                $result[$key] = self::create(
4849
                    $item,
4850
                    $this->iteratorClass,
4851
                    false
4852
                )->prependToEachValue($suffix)
4853
                    ->toArray();
4854
            } elseif (\is_object($item) === true) {
4855
                $result[$key] = $item;
4856
            } else {
4857
                $result[$key] = $item . $suffix;
4858
            }
4859
        }
4860
4861
        return self::create(
4862
            $result,
4863
            $this->iteratorClass,
4864
            false
4865
        );
4866
    }
4867
4868
    /**
4869
     * Return the value of a given key and