Code Duplication    Length = 11-12 lines in 3 locations

src/Arrayy.php 3 locations

@@ 2239-2249 (lines=11) @@
2236
     * @psalm-return static<TKey,T>
2237
     * @psalm-mutation-free
2238
     */
2239
    public function each(\Closure $closure): self
2240
    {
2241
        // init
2242
        $array = [];
2243
2244
        foreach ($this->getGenerator() as $key => $value) {
2245
            $array[$key] = $closure($value, $key);
2246
        }
2247
2248
        return static::create(
2249
            $array,
2250
            $this->iteratorClass,
2251
            false
2252
        );
@@ 5151-5162 (lines=12) @@
5148
     * @psalm-return static<TKey,T>
5149
     * @psalm-mutation-free
5150
     */
5151
    public function reduce($callable, $initial = []): self
5152
    {
5153
        foreach ($this->getGenerator() as $key => $value) {
5154
            $initial = $callable($initial, $value, $key);
5155
        }
5156
5157
        return static::create(
5158
            $initial,
5159
            $this->iteratorClass,
5160
            false
5161
        );
5162
    }
5163
5164
    /**
5165
     * @param bool $unique
@@ 5236-5247 (lines=12) @@
5233
     * @psalm-return static<TKey,T>
5234
     * @psalm-mutation-free
5235
     */
5236
    public function reject(\Closure $closure): self
5237
    {
5238
        // init
5239
        $filtered = [];
5240
5241
        foreach ($this->getGenerator() as $key => $value) {
5242
            if (!$closure($value, $key)) {
5243
                $filtered[$key] = $value;
5244
            }
5245
        }
5246
5247
        return static::create(
5248
            $filtered,
5249
            $this->iteratorClass,
5250
            false