We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 7 |
| Paths | 7 |
| Total Lines | 23 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 7 |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 25 | 28 | public function validate($input) |
|
| 26 | { |
||
| 27 | 28 | if ($input instanceof DateTime) { |
|
| 28 | 1 | return true; |
|
| 29 | 27 | } elseif (!(is_string($input) || is_int($input))) { |
|
| 30 | 1 | return false; |
|
| 31 | 26 | } elseif (is_null($this->format)) { |
|
| 32 | 5 | return false !== strtotime($input); |
|
| 33 | } |
||
| 34 | |||
| 35 | $exceptionalFormats = [ |
||
| 36 | 21 | 'c' => 'Y-m-d\TH:i:sP', |
|
| 37 | 21 | 'r' => 'D, d M Y H:i:s O', |
|
| 38 | 21 | ]; |
|
| 39 | |||
| 40 | 21 | if (in_array($this->format, array_keys($exceptionalFormats))) { |
|
| 41 | 7 | $this->format = $exceptionalFormats[ $this->format ]; |
|
| 42 | 7 | } |
|
| 43 | |||
| 44 | 21 | $info = date_parse_from_format($this->format, $input); |
|
| 45 | |||
| 46 | 21 | return ($info['error_count'] === 0 && $info['warning_count'] === 0); |
|
| 47 | } |
||
| 48 | } |
||
| 49 |