Completed
Push — master ( 87eb9e...2b0bcc )
by Serhii
11s
created

PerformanceEventRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 35
ccs 9
cts 10
cp 0.9
rs 10
c 1
b 1
f 0
wmc 3
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
B findByDateRangeAndSlug() 0 25 3
1
<?php
2
3
namespace AppBundle\Repository;
4
5
class PerformanceEventRepository extends AbstractRepository
6
{
7 2
    /**
8
     * @param \DateTime $fromDate
9 2
     * @param \DateTime $toDate
10 2
     * @param string $limit
11 2
     * @param null $performanceSlug
12 2
     * @return mixed
13 2
     */
14
    public function findByDateRangeAndSlug(
15
        \DateTime $fromDate,
16 2
        \DateTime $toDate,
17
        $limit = 'all',
18
        $performanceSlug = null
19
    ) {
20 2
        $qb = $this->createQueryBuilder('u')
21
            ->WHERE('u.dateTime BETWEEN :from AND :to')
22 2
            ->setParameter('from', $fromDate->format('Y-m-d H:i'))
23
            ->setParameter('to', $toDate->format('Y-m-d H:i'))
24
            ->orderBy('u.dateTime', 'ASC')
25
        ;
26
27
        if ('all' !== $limit) {
28
            $qb->setMaxResults($limit);
29
        }
30
31
        if ($performanceSlug) {
32
            $qb->join('u.performance', 'p')->andWhere('p.slug = :slug')->setParameter('slug', $performanceSlug);
33
        }
34
35
        $query = $qb->getQuery();
36
37
        return $query->execute();
38
    }
39
}
40