TestResultRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 30
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getResults() 0 11 1
A getResultsOlderThan() 0 15 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