| Conditions | 4 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 4.25 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | 1 | public function convertToSQL($value) |
|
| 34 | { |
||
| 35 | 1 | if ($value === null || $value === '') { |
|
| 36 | return null; |
||
| 37 | } |
||
| 38 | |||
| 39 | 1 | $timestamp = (int) $value; |
|
| 40 | |||
| 41 | 1 | if ($timestamp === 0) { |
|
| 42 | throw new UnexpectedValueException("unable to convert value to int: " . $value); |
||
| 43 | } |
||
| 44 | |||
| 45 | 1 | $datetime = DateTime::createFromFormat('U', $timestamp, self::getTimeZone()); |
|
| 46 | |||
| 47 | 1 | return $datetime->format(static::FORMAT); |
|
| 48 | } |
||
| 49 | |||
| 69 |