Code Duplication    Length = 10-12 lines in 2 locations

src/Collection.php 2 locations

@@ 13-22 (lines=10) @@
10
     * @param string $entityMethod
11
     * @return static
12
     */
13
    public function rebuildByEntityMethod($entityMethod)
14
    {
15
        $newCollection = new static();
16
17
        foreach ($this->getArrayCopy() as $entity) {
18
            $newCollection->offsetSet($entity->$entityMethod(), $entity);
19
        }
20
21
        return $newCollection;
22
    }
23
24
    /**
25
     * @param string $entityMethod
@@ 44-55 (lines=12) @@
41
     * @param mixed $value
42
     * @return static
43
     */
44
    public function filter($entityMethod, $value)
45
    {
46
        $newCollection = new static();
47
48
        foreach ($this->getArrayCopy() as $entity) {
49
            if ($entity->$entityMethod() == $value) {
50
                $newCollection->offsetSet($entity->getId(), $entity);
51
            }
52
        }
53
54
        return $newCollection;
55
    }
56
57
    /**
58
     * @return Collection