Conditions | 6 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | public function apply(QueryBuilder $queryBuilder) |
||
34 | { |
||
35 | if (null !== $this->startDate && null !== $this->endDate && $this->endDate < $this->startDate) { |
||
36 | throw new \InvalidArgumentException('End date must be greater than start date.'); |
||
37 | } |
||
38 | |||
39 | if (null !== $this->startDate) { |
||
40 | $queryBuilder |
||
41 | ->andWhere('created_at >= :start_date') |
||
42 | ->setParameter('start_date', $this->startDate->format('Y-m-d H:i:s')) |
||
43 | ; |
||
44 | } |
||
45 | |||
46 | if (null !== $this->endDate) { |
||
47 | $queryBuilder |
||
48 | ->andWhere('created_at <= :end_date') |
||
49 | ->setParameter('end_date', $this->endDate->format('Y-m-d H:i:s')) |
||
50 | ; |
||
54 |