Failed Conditions
Pull Request — master (#142)
by Zac
04:15
created

TestResultRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

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

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
    public function getResults($criteria, $pageSize = 10, $page = 1)
14
    {
15
        return $this->findBy(
16
            $criteria,
17
            [
18
                'createdAt' => 'desc'
19
            ],
20
            $pageSize,
21
            ($page - 1) * $pageSize
22
        );
23
    }
24
25
    public function getResultsOlderThan(\DateTime $date)
26
    {
27
        $qb = $this->createQueryBuilder('r');
28
        $qb
29
            ->where(
30
                $qb->expr()->lt(
31
                    'r.createdAt',
32
                    ':timestamp'
33
                )
34
            )
35
            ->setParameter('timestamp', $date)
36
        ;
37
38
        return $qb->getQuery()->iterate();
39
    }
40
}
41