| Conditions | 2 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public static function getUnixTime(string $logLine, int $year = null) |
||
| 32 | { |
||
| 33 | // I can read month and day and time from the file. |
||
| 34 | // but I will assume year is current year retured by time(). |
||
| 35 | // Unless month and day in the file is bigger than current month and day, |
||
| 36 | // I will then assume previous year. |
||
| 37 | // A better approach would be to get the year from last modification time (mtime) of the |
||
| 38 | // file this record is taken from. But that requires knowledge about the file. |
||
| 39 | if ($year === null) { |
||
| 40 | $now = getdate(); |
||
| 41 | $year = intval($now['year']); |
||
| 42 | } |
||
| 43 | list($month, $day, $hour, $minute, $second) = sscanf($logLine, "%s %d %d:%d:%d "); |
||
| 44 | $time = sprintf("%d %s %d %d:%d:%d", $day, $month, $year, $hour, $minute, $second); |
||
| 45 | return strtotime($time); |
||
| 46 | } |
||
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.