Completed
Pull Request — master (#147)
by
unknown
21:40 queued 11:18
created

PerformanceEventRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 35
ccs 12
cts 12
cp 1
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
    /**
8
     * @param \DateTime $fromDate
9
     * @param \DateTime $toDate
10
     * @param string $limit
11
     * @param null $performanceSlug
12
     * @return mixed
13
     */
14 6
    public function findByDateRangeAndSlug(
15
        \DateTime $fromDate,
16
        \DateTime $toDate,
17
        $limit = null,
18
        $performanceSlug = null
19
    ) {
20 6
        $qb = $this->createQueryBuilder('u')
21 6
            ->where('u.dateTime BETWEEN :from AND :to')
22 6
            ->setParameter('from', $fromDate->format('Y-m-d H:i'))
23 6
            ->setParameter('to', $toDate->format('Y-m-d H:i'))
24 6
            ->orderBy('u.dateTime', 'ASC')
25
        ;
26
27 6
        if ($limit) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $limit of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
28 3
            $qb->setMaxResults($limit);
29
        }
30
31 6
        if ($performanceSlug) {
32 2
            $qb->join('u.performance', 'p')->andWhere('p.slug = :slug')->setParameter('slug', $performanceSlug);
33
        }
34
35 6
        $query = $qb->getQuery();
36
37 6
        return $query->execute();
38
    }
39
}
40