Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
TimeParser | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
time_str_to_seconds | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Parsers; |
4 | |
5 | class TimeParser { |
6 | public function time_str_to_seconds(string $time_str): int { |
7 | $res = preg_match("/^(([0-9]+)[:\\.])?([0-9]+)[:\\.]([0-9]+)$/", $time_str, $matches); |
8 | if (!$res) { |
9 | return -1; |
10 | } |
11 | $h = intval($matches[2]); |
12 | $m = intval($matches[3]); |
13 | $s = intval($matches[4]); |
14 | return $h * 3600 + $m * 60 + $s; |
15 | } |
16 | } |