| Conditions | 6 |
| Paths | 5 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | function dateToUnix($timestamp): int |
||
| 35 | { |
||
| 36 | if (is_int($timestamp)) { |
||
| 37 | return $timestamp; |
||
| 38 | } |
||
| 39 | |||
| 40 | if (is_object($timestamp)) { |
||
| 41 | return $timestamp->getTimestamp(); |
||
| 42 | } |
||
| 43 | |||
| 44 | if ($timestamp !== null) { |
||
|
|
|||
| 45 | $unix = strtotime($timestamp); |
||
| 46 | if ($unix < 0 || $unix === false) { |
||
| 47 | throw new \RuntimeException( |
||
| 48 | "Can't convert timestamp $timestamp to unix-timestamp.", |
||
| 49 | 1524230476 |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | return $unix; |
||
| 54 | } |
||
| 55 | |||
| 56 | throw new \RuntimeException(); |
||
| 57 | } |
||
| 58 | |||
| 69 |