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