| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public static function createDateTime($value) |
||
| 49 | { |
||
| 50 | if ($value instanceOf \DateTime) { |
||
| 51 | return $value; |
||
| 52 | } |
||
| 53 | |||
| 54 | if (is_numeric($value)) { |
||
| 55 | return new \DateTime( |
||
| 56 | sprintf("@%d", (int) $value), |
||
| 57 | new \DateTimeZone(date_default_timezone_get()) |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | if (is_string($value)) { |
||
| 62 | return new \DateTime($value, new \DateTimeZone(date_default_timezone_get())); |
||
| 63 | } |
||
| 64 | |||
| 65 | return new \DateTime(); |
||
| 66 | } |
||
| 68 |