Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
32 | 4 | public function getOverlappedEntities( |
|
33 | string $entityClass, |
||
34 | string $fromDateProperty, |
||
35 | string $toDateProperty, |
||
36 | \DateTimeInterface $fromDate, |
||
37 | \DateTimeInterface $toDate |
||
38 | ): array { |
||
39 | 4 | $where = '(e._from >= :fromDate AND e._from <= :toDate) OR (:fromDate >= e._from AND :fromDate <= e._to)'; |
|
40 | 4 | $where = str_replace(['_from', '_to'], [$fromDateProperty, $toDateProperty], $where); |
|
41 | |||
42 | 4 | return $this->entityManager |
|
43 | 4 | ->createQueryBuilder() |
|
44 | 4 | ->select('e') |
|
45 | 4 | ->from($entityClass, 'e') |
|
46 | 4 | ->where($where) |
|
47 | 4 | ->setParameters([ |
|
48 | 4 | 'fromDate' => $fromDate->format(ApplicationEnum::DATE_FORMAT), |
|
49 | 4 | 'toDate' => $toDate->format(ApplicationEnum::DATE_FORMAT), |
|
50 | ]) |
||
51 | 4 | ->getQuery() |
|
52 | 4 | ->getResult() |
|
53 | ; |
||
54 | } |
||
55 | } |
||
56 |