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