| Conditions | 5 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5.2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | 1 | protected function formatDefault() |
|
| 21 | { |
||
| 22 | // Check if this is an ISO8601 datetime format (in the UTC timezone). |
||
| 23 | 1 | if (true == preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/', $this->input)) { |
|
|
|
|||
| 24 | // Check that PHP can build a date object from the input. |
||
| 25 | return (false !== \DateTime::createFromFormat(DATE_ISO8601, $this->input)); |
||
| 26 | } |
||
| 27 | |||
| 28 | 1 | if ($this->formatDate('Y-m-d H:i:s')) { |
|
| 29 | 1 | return true; |
|
| 30 | } |
||
| 31 | |||
| 32 | 1 | if ($this->formatDate('Y-m-d')) { |
|
| 33 | 1 | return true; |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | if ($this->formatDate('H:i:s')) { |
|
| 37 | 1 | return true; |
|
| 38 | } |
||
| 39 | |||
| 40 | // The input didn't match any of the expected formats. |
||
| 41 | return false; |
||
| 42 | } |
||
| 43 | |||
| 61 |