| Conditions | 4 |
| Paths | 6 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 2 | public function isValid($value, array $parameters) |
|
| 26 | { |
||
| 27 | 2 | $format = 'Y-m-d H:i:s'; |
|
| 28 | 2 | if (count($parameters) > 0) { |
|
| 29 | 1 | $format = $parameters[0]; |
|
| 30 | } |
||
| 31 | 2 | if (in_array($value, ['', null], true)) { |
|
| 32 | 2 | return true; |
|
| 33 | } |
||
| 34 | $dateTime = \DateTime::createFromFormat($format, $value); |
||
| 35 | return $dateTime && $dateTime->format($format) === $value; |
||
| 36 | } |
||
| 46 |