Conditions | 3 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
17 | 1 | protected function withPropertyConstraint(Builder $query, $value, $property): Builder |
|
18 | { |
||
19 | 1 | $formatter = function ($value) { |
|
20 | 1 | return $value instanceof DateTimeInterface ? $value->format('Y-m-d') : $value; |
|
21 | }; |
||
22 | 1 | if (\is_array($value)) { |
|
23 | 1 | $value = array_map($formatter, $value); |
|
24 | |||
25 | 1 | return $query->whereIn(DB::raw(sprintf('date(%s)', $property)), $value); |
|
|
|||
26 | } |
||
27 | |||
28 | 1 | $value = $formatter($value); |
|
29 | |||
30 | 1 | return $query->whereDate($property, $value); |
|
31 | } |
||
33 |