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

@@ 377-392 (lines=16) @@
374
     * {@inheritDoc}
375
     * @return $this
376
     */
377
    public function groupBy($callback)
378
    {
379
        $group = new Map();
380
        foreach ($this as $value) {
381
            $key = $callback($value);
382
            if (!$group->containsKey($key)) {
383
                $element = $this instanceof VectorInterface ? new static([$value]) : new Vector([$value]);
384
                $group->add(new Pair($key, $element));
385
            } else {
386
                $value = $group->get($key)->add($value);
387
                $group->set($key, $value);
388
            }
389
        }
390
391
        return $group;
392
    }
393
394
    /**
395
     * {@inheritDoc}