Completed
Pull Request — master (#15)
by Wachter
10:36
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 4
Bugs 0 Features 2
Metric Value
wmc 3
c 4
b 0
f 2
lcom 1
cbo 3
dl 0
loc 31
ccs 17
cts 17
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\Storage\TaskRepositoryInterface;
7
use Task\TaskInterface;
8
9 6
class TaskRepository extends EntityRepository implements TaskRepositoryInterface
10
{
11 6
    /**
12 6
     * {@inheritdoc}
13 6
     */
14 6
    public function findEndBefore(\DateTime $dateTime)
15 6
    {
16 6
        return $this->createQueryBuilder('t')
17
            ->where('t.lastExecution IS NOT NULL OR t.lastExecution > :dateTime')
18 6
            ->setParameter('dateTime', $dateTime)
19
            ->getQuery()
20
            ->getResult();
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26 3
    public function add(TaskInterface $task)
27
    {
28 3
        $this->_em->persist($task);
29 3
        $this->_em->flush();
30 3
    }
31 3
32
    /**
33 3
     * {@inheritdoc}
34
     */
35
    public function findEndBeforeNow()
36 6
    {
37
        return $this->findEndBefore(new \DateTime());
38 6
    }
39
}
40