| Conditions | 8 |
| Paths | 8 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public static function toNanos(int $duration, string $units): int |
||
| 16 | { |
||
| 17 | if (strtolower($units) == self::DAYS) { |
||
| 18 | return $duration * 86400000000000; |
||
| 19 | } |
||
| 20 | if (strtolower($units) == self::HOURS) { |
||
| 21 | return $duration * 3600000000000; |
||
| 22 | } |
||
| 23 | if (strtolower($units) == self::MICROSECONDS) { |
||
| 24 | return $duration * 1000; |
||
| 25 | } |
||
| 26 | if (strtolower($units) == self::MILLISECONDS) { |
||
| 27 | return $duration * 1000000; |
||
| 28 | } |
||
| 29 | if (strtolower($units) == self::MINUTES) { |
||
| 30 | return $duration * 60000000000; |
||
| 31 | } |
||
| 32 | if (strtolower($units) == self::NANOSECONDS) { |
||
| 33 | return $duration; |
||
| 34 | } |
||
| 35 | if (strtolower($units) == self::SECONDS) { |
||
| 36 | return $duration * 1000000000; |
||
| 37 | } |
||
| 40 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: