Code Duplication    Length = 16-16 lines in 3 locations

src/Iterator/LazyIterableTrait.php 1 location

@@ 176-191 (lines=16) @@
173
     * {@inheritDoc}
174
     * @return $this
175
     */
176
    public function groupBy($callback)
177
    {
178
        $group = new Map();
179
        foreach ($this as $value) {
180
            $key = $callback($value);
181
            if (!$group->containsKey($key)) {
182
                $element = $this instanceof VectorInterface ? new static([$value]) : new Vector([$value]);
183
                $group->add(new Pair($key, $element));
184
            } else {
185
                $value = $group->get($key)->add($value);
186
                $group->set($key, $value);
187
            }
188
        }
189
190
        return $group;
191
    }
192
193
    /**
194
     * {@inheritDoc}

src/Iterator/LazyKeyedIterableTrait.php 1 location

@@ 234-249 (lines=16) @@
231
     * {@inheritDoc}
232
     * @return $this
233
     */
234
    public function groupBy($callback)
235
    {
236
        $group = new Map();
237
        foreach ($this as $value) {
238
            $key = $callback($value);
239
            if (!$group->containsKey($key)) {
240
                $element = $this instanceof VectorInterface ? new static([$value]) : new Vector([$value]);
241
                $group->add(new Pair($key, $element));
242
            } else {
243
                $value = $group->get($key)->add($value);
244
                $group->set($key, $value);
245
            }
246
        }
247
248
        return $group;
249
    }
250
251
    /**
252
     * {@inheritDoc}

src/Traits/CommonContainerMethodsTrait.php 1 location

@@ 364-379 (lines=16) @@
361
     * {@inheritDoc}
362
     * @return $this
363
     */
364
    public function groupBy($callback)
365
    {
366
        $group = new Map();
367
        foreach ($this as $value) {
368
            $key = $callback($value);
369
            if (!$group->containsKey($key)) {
370
                $element = $this instanceof VectorInterface ? new static([$value]) : new Vector([$value]);
371
                $group->add(new Pair($key, $element));
372
            } else {
373
                $value = $group->get($key)->add($value);
374
                $group->set($key, $value);
375
            }
376
        }
377
378
        return $group;
379
    }
380
381
    /**
382
     * {@inheritDoc}