TestResultRepository::getResultsOlderThan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Overwatch\ResultBundle\Entity;
4
5
use Doctrine\ORM\EntityRepository;
6
7
/**
8
 * TestResultRepository
9
 * Some shortcut and convienience methods to find test results
10
 */
11
class TestResultRepository extends EntityRepository
12
{
13 13
    public function getResults($criteria, $pageSize = 10, $page = 1)
14
    {
15 13
        return $this->findBy(
16 13
            $criteria,
17
            [
18
                'createdAt' => 'desc'
19 13
            ],
20 13
            $pageSize,
21 13
            ($page - 1) * $pageSize
22 13
        );
23
    }
24
25 5
    public function getResultsOlderThan(\DateTime $date)
26
    {
27 5
        $qb = $this->createQueryBuilder('r');
28
        $qb
29 5
            ->where(
30 5
                $qb->expr()->lt(
31 5
                    'r.createdAt',
32
                    ':timestamp'
33 5
                )
34 5
            )
35 5
            ->setParameter('timestamp', $date)
36
        ;
37
38 5
        return $qb->getQuery()->iterate();
39
    }
40
}
41