Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1082-1100 (lines=19) @@
1079
     * @phpstan-return static<TKey,T>
1080
     * @psalm-mutation-free
1081
     */
1082
    public function appendToEachValue($prefix): self
1083
    {
1084
        // init
1085
        $result = [];
1086
1087
        foreach ($this->getGenerator() as $key => $item) {
1088
            if ($item instanceof self) {
1089
                $result[$key] = $item->appendToEachValue($prefix);
1090
            } elseif (\is_array($item)) {
1091
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1092
            } elseif (\is_object($item) === true) {
1093
                $result[$key] = $item;
1094
            } else {
1095
                $result[$key] = $prefix . $item;
1096
            }
1097
        }
1098
1099
        return self::create($result, $this->iteratorClass, false);
1100
    }
1101
1102
    /**
1103
     * Sort an array in reverse order and maintain index association.
@@ 4966-4993 (lines=28) @@
4963
     * @phpstan-return static<TKey,T>
4964
     * @psalm-mutation-free
4965
     */
4966
    public function prependToEachValue($suffix): self
4967
    {
4968
        // init
4969
        $result = [];
4970
4971
        foreach ($this->getGenerator() as $key => $item) {
4972
            if ($item instanceof self) {
4973
                $result[$key] = $item->prependToEachValue($suffix);
4974
            } elseif (\is_array($item)) {
4975
                $result[$key] = self::create(
4976
                    $item,
4977
                    $this->iteratorClass,
4978
                    false
4979
                )->prependToEachValue($suffix)
4980
                    ->toArray();
4981
            } elseif (\is_object($item) === true) {
4982
                $result[$key] = $item;
4983
            } else {
4984
                $result[$key] = $item . $suffix;
4985
            }
4986
        }
4987
4988
        return self::create(
4989
            $result,
4990
            $this->iteratorClass,
4991
            false
4992
        );
4993
    }
4994
4995
    /**
4996
     * Return the value of a given key and