| Conditions | 4 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4.0119 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 6 | public function validate($received, string $format, string $max): bool |
|
| 32 | { |
||
| 33 | 6 | $dateReceived = DateTime::createFromFormat($format, $received); |
|
| 34 | 6 | $dateMax = DateTime::createFromFormat($format, $max); |
|
| 35 | |||
| 36 | 6 | if (!($dateMax && $dateReceived)) { |
|
| 37 | return true; |
||
| 38 | } |
||
| 39 | |||
| 40 | 6 | $dateMax->setTime(0, 0, 0); |
|
| 41 | 6 | $dateReceived->setTime(0, 0, 0); |
|
| 42 | |||
| 43 | 6 | if ($dateMax->format('Ymd') >= $dateReceived->format('Ymd')) { |
|
| 44 | 4 | $this->date = $dateReceived; |
|
| 45 | 4 | return false; |
|
| 46 | } |
||
| 47 | |||
| 48 | 2 | return true; |
|
| 49 | } |
||
| 61 |