Conditions | 3 |
Paths | 4 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
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) { |
|
|
|||
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 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
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: