Completed
Pull Request — master (#15)
by Wachter
24:49 queued 08:56
created

TaskRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 2
Metric Value
wmc 3
c 5
b 0
f 2
lcom 1
cbo 3
dl 0
loc 31
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findEndBefore() 0 8 1
A add() 0 5 1
A findEndBeforeNow() 0 4 1
1
<?php
2
3
namespace Task\TaskBundle\Entity;
4
5
use Doctrine\ORM\EntityRepository;
6
use Task\TaskInterface;
7
8
class TaskRepository extends EntityRepository
9 6
{
10
    /**
11 6
     * {@inheritdoc}
12 6
     */
13 6
    public function findEndBefore(\DateTime $dateTime)
14 6
    {
15 6
        return $this->createQueryBuilder('t')
16 6
            ->where('t.lastExecution IS NULL OR t.lastExecution >= :dateTime')
17
            ->setParameter('dateTime', $dateTime)
18 6
            ->getQuery()
19
            ->getResult();
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function add(TaskInterface $task)
26 3
    {
27
        $this->_em->persist($task);
28 3
        $this->_em->flush();
29 3
    }
30 3
31 3
    /**
32
     * {@inheritdoc}
33 3
     */
34
    public function findEndBeforeNow()
35
    {
36 6
        return $this->findEndBefore(new \DateTime());
37
    }
38
}
39