Completed
Pull Request — master (#15)
by Wachter
06:01
created

TaskRepository::findEndBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of php-task library.
5
 *
6
 * (c) php-task
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Task\TaskBundle\Entity;
13
14
use Doctrine\ORM\EntityRepository;
15
use Task\TaskInterface;
16
17
/**
18
 * Repository for task.
19
 */
20
class TaskRepository extends EntityRepository
21
{
22
    /**
23
     * Returns task where last-execution is before given date-time.
24
     *
25
     * @param \DateTime $dateTime
26
     *
27
     * @return TaskInterface[]
28
     */
29
    public function findEndBefore(\DateTime $dateTime)
30
    {
31
        return $this->createQueryBuilder('t')
32
            ->where('t.lastExecution IS NULL OR t.lastExecution >= :dateTime')
33
            ->setParameter('dateTime', $dateTime)
34
            ->getQuery()
35
            ->getResult();
36
    }
37
}
38