Code Duplication    Length = 19-28 lines in 2 locations

src/Arrayy.php 2 locations

@@ 1101-1119 (lines=19) @@
1098
     * @phpstan-return static<TKey,T>
1099
     * @psalm-mutation-free
1100
     */
1101
    public function appendToEachValue($prefix): self
1102
    {
1103
        // init
1104
        $result = [];
1105
1106
        foreach ($this->getGenerator() as $key => $item) {
1107
            if ($item instanceof self) {
1108
                $result[$key] = $item->appendToEachValue($prefix);
1109
            } elseif (\is_array($item)) {
1110
                $result[$key] = self::create($item, $this->iteratorClass, false)->appendToEachValue($prefix)->toArray();
1111
            } elseif (\is_object($item) === true) {
1112
                $result[$key] = $item;
1113
            } else {
1114
                $result[$key] = $prefix . $item;
1115
            }
1116
        }
1117
1118
        return self::create($result, $this->iteratorClass, false);
1119
    }
1120
1121
    /**
1122
     * Sort an array in reverse order and maintain index association.
@@ 5004-5031 (lines=28) @@
5001
     * @phpstan-return static<TKey,T>
5002
     * @psalm-mutation-free
5003
     */
5004
    public function prependToEachValue($suffix): self
5005
    {
5006
        // init
5007
        $result = [];
5008
5009
        foreach ($this->getGenerator() as $key => $item) {
5010
            if ($item instanceof self) {
5011
                $result[$key] = $item->prependToEachValue($suffix);
5012
            } elseif (\is_array($item)) {
5013
                $result[$key] = self::create(
5014
                    $item,
5015
                    $this->iteratorClass,
5016
                    false
5017
                )->prependToEachValue($suffix)
5018
                    ->toArray();
5019
            } elseif (\is_object($item) === true) {
5020
                $result[$key] = $item;
5021
            } else {
5022
                $result[$key] = $item . $suffix;
5023
            }
5024
        }
5025
5026
        return self::create(
5027
            $result,
5028
            $this->iteratorClass,
5029
            false
5030
        );
5031
    }
5032
5033
    /**
5034
     * Return the value of a given key and