Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0416 |
Changes | 0 |
1 | <?php |
||
16 | 2 | public function getProgress(string $line): ?array |
|
17 | { |
||
18 | 2 | $line = str_replace(' ', '', $line); |
|
19 | |||
20 | 2 | $result = preg_match('/frame=(?P<frame>\d+)(.*)size=(?P<size>\d+(KB|MB|B))(.*)time=(?P<time>([0-9\.:]+))(.*)speed=(?P<speed>([0-9\.]+))x/i', $line, $matches); |
|
21 | |||
22 | 2 | if ($result === 1) { |
|
23 | try { |
||
24 | 1 | $time = SeekTime::convertHMSmToSeconds($matches['time']); |
|
25 | } catch (InvalidArgumentException $e) { |
||
26 | $time = 0; |
||
27 | } |
||
28 | |||
29 | return [ |
||
30 | 1 | 'frame' => (int) $matches['frame'], |
|
31 | 1 | 'size' => $matches['size'], |
|
32 | 1 | 'time' => $time, |
|
33 | 1 | 'speed' => (float) $matches['speed'], |
|
34 | ]; |
||
35 | } |
||
36 | |||
37 | 1 | return null; |
|
38 | } |
||
40 |