Completed
Pull Request — master (#26)
by Julien
04:20
created

EventRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 0
cbo 0
dl 0
loc 27
ccs 0
cts 13
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A findFirstTodoEvent() 0 17 3
1
<?php
2
3
namespace Itkg\DelayEventBundle\Repository;
4
5
use Doctrine\ODM\MongoDB\DocumentRepository;
6
use Itkg\DelayEventBundle\Model\Event;
7
8
/**
9
 * Class EventRepository
10
 */
11
class EventRepository extends DocumentRepository
12
{
13
    /**
14
     * @param bool  $failed
15
     * @param array $eventTypeIncluded
16
     * @param array $eventTypeExcluded
17
     *
18
     * @return Event
19
     */
20
    public function findFirstTodoEvent($failed = false, array $eventTypeIncluded = [], array $eventTypeExcluded = [])
21
    {
22
        $qb = $this->createQueryBuilder();
23
        $qb->field('failed')->equals($failed);
24
25
        if (!empty($eventTypeIncluded)) {
26
            $qb->field('originalName')->in($eventTypeIncluded);
27
        }
28
29
        if (!empty($eventTypeExcluded)) {
30
            $qb->field('originalName')->notIn($eventTypeExcluded);
31
        }
32
33
        $qb->sort('createdAt', 'asc');
34
35
        return $qb->getQuery()->getSingleResult();
36
    }
37
}
38