Completed
Pull Request — master (#15)
by Wachter
08:18 queued 05:27
created

TaskRepository::findEndBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
crap 1
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 6
 * with this source code in the file LICENSE.
10
 */
11 6
12 6
namespace Task\TaskBundle\Entity;
13 6
14 6
use Doctrine\ORM\EntityRepository;
15 6
use Task\TaskInterface;
16 6
17
/**
18 6
 * 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 3
     *
27
     * @return TaskInterface[]
28 3
     */
29 3
    public function findEndBefore(\DateTime $dateTime)
30 3
    {
31 3
        return $this->createQueryBuilder('t')
32
            ->where('t.lastExecution IS NULL OR t.lastExecution >= :dateTime')
33 3
            ->setParameter('dateTime', $dateTime)
34
            ->getQuery()
35
            ->getResult();
36 6
    }
37
}
38