Completed
Push — master ( cc2045...c73ac3 )
by Serhii
25:51 queued 25:43
created

findByDateRangeAndSlug()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2.004

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 3
dl 0
loc 17
ccs 9
cts 10
cp 0.9
crap 2.004
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace AppBundle\Repository;
4
5
class PerformanceEventRepository extends AbstractRepository
6
{
7 2
    public function findByDateRangeAndSlug(\DateTime $fromDate, \DateTime $toDate, $performanceSlug = null)
8
    {
9 2
        $qb = $this->createQueryBuilder('u')
10 2
            ->WHERE('u.dateTime BETWEEN :from AND :to')
11 2
            ->setParameter('from', $fromDate->format('Y-m-d H:i'))
12 2
            ->setParameter('to', $toDate->format('Y-m-d H:i'))
13 2
            ->orderBy('u.dateTime', 'ASC')
14
        ;
15
16 2
        if ($performanceSlug) {
17
            $qb->join('u.performance', 'p')->andWhere('p.slug = :slug')->setParameter('slug', $performanceSlug);
18
        }
19
20 2
        $query = $qb->getQuery();
21
22 2
        return $query->execute();
23
    }
24
}
25