Completed
Pull Request — master (#15)
by Wachter
10:36
created

TaskRepository::deleteAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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