Conditions | 5 |
Paths | 7 |
Total Lines | 37 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 5.0291 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | 3 | protected function chromeVersion($os) |
|
35 | { |
||
36 | 3 | $path = $this->option('detect'); |
|
|
|||
37 | |||
38 | 3 | if ($path) { |
|
39 | 2 | if ($os === 'win') { |
|
40 | $this->error('Chrome version cannot be detected in custom installation path on Windows.'); |
||
41 | |||
42 | return false; |
||
43 | } |
||
44 | |||
45 | 2 | $commands = [$path.' --version']; |
|
46 | } else { |
||
47 | 1 | $commands = $this->chromeCommands[$os]; |
|
48 | } |
||
49 | |||
50 | 3 | foreach ($commands as $command) { |
|
51 | 3 | $process = Process::fromShellCommandline($command); |
|
52 | |||
53 | 3 | $process->run(); |
|
54 | |||
55 | 3 | preg_match('/(\d+)(\.\d+){3}/', $process->getOutput(), $matches); |
|
56 | |||
57 | 3 | if (!isset($matches[1])) { |
|
58 | 1 | continue; |
|
59 | } |
||
60 | |||
61 | 2 | $this->comment( |
|
62 | 2 | sprintf('Chrome version %s detected.', $matches[0]) |
|
63 | ); |
||
64 | |||
65 | 2 | return (int) $matches[1]; |
|
66 | } |
||
67 | |||
68 | 1 | $this->error('Chrome version could not be detected. Please submit an issue: https://github.com/staudenmeir/dusk-updater'); |
|
69 | |||
70 | 1 | return false; |
|
71 | } |
||
73 |