Completed
Pull Request — master (#15)
by Wachter
07:53
created

TaskRepository::findEndBeforeNow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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