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

TaskRepository::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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