| Conditions | 7 |
| Paths | 9 |
| Total Lines | 22 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | public function parse($rawValue) |
||
| 40 | { |
||
| 41 | if ($rawValue === null || $rawValue === '') { |
||
| 42 | return null; |
||
| 43 | } |
||
| 44 | |||
| 45 | if ($this->format) { |
||
|
|
|||
| 46 | $date = \DateTime::createFromFormat($this->format, $rawValue); |
||
| 47 | } else { |
||
| 48 | $date = new \DateTime($rawValue); |
||
| 49 | } |
||
| 50 | |||
| 51 | $errors = \DateTime::getLastErrors(); |
||
| 52 | if ($errors['error_count'] > 0) { |
||
| 53 | $this->throw(); |
||
| 54 | } |
||
| 55 | if (!$this->ignoreWarnings && $errors['warning_count'] > 0) { |
||
| 56 | $this->throw(); |
||
| 57 | } |
||
| 58 | |||
| 59 | return $date; |
||
| 60 | } |
||
| 61 | } |
||
| 62 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: