diff --git a/src/Console/ChromeDriverCommand.php b/src/Console/ChromeDriverCommand.php index 032c52d6e..10cc01412 100644 --- a/src/Console/ChromeDriverCommand.php +++ b/src/Console/ChromeDriverCommand.php @@ -105,11 +105,11 @@ class ChromeDriverCommand extends Command protected $directory = __DIR__.'/../../bin/'; /** - * The default commands to detect the installed Chrome/Chromium version. + * The default commands to detect the installed Chrome / Chromium version. * * @var array */ - protected $chromeCommands = [ + protected $chromeVersionCommands = [ 'linux' => [ '/usr/bin/google-chrome --version', '/usr/bin/chromium-browser --version', @@ -161,7 +161,7 @@ protected function version() $version = $this->argument('version'); if ($this->option('detect')) { - $version = $this->chromeVersion(OperatingSystem::id()); + $version = $this->detectChromeVersion(OperatingSystem::id()); } if (! $version) { @@ -208,6 +208,33 @@ protected function latestVersion() return trim(file_get_contents($this->latestVersionUrl, false, stream_context_create($streamOptions))); } + /** + * Detect the installed Chrome / Chromium major version. + * + * @param string $os + * @return int|bool + */ + protected function detectChromeVersion($os) + { + foreach ($this->chromeVersionCommands[$os] as $command) { + $process = Process::fromShellCommandline($command); + + $process->run(); + + preg_match('/(\d+)(\.\d+){3}/', $process->getOutput(), $matches); + + if (! isset($matches[1])) { + continue; + } + + return $matches[1]; + } + + $this->error('Chrome version could not be detected.'); + + return false; + } + /** * Download the ChromeDriver archive. * @@ -288,31 +315,4 @@ protected function getUrl(string $url) return file_get_contents($url, false, $streamContext); } - - /** - * Detect the installed Chrome/Chromium major version. - * - * @param string $os - * @return int|bool - */ - protected function chromeVersion($os) - { - foreach ($this->chromeCommands[$os] as $command) { - $process = Process::fromShellCommandline($command); - - $process->run(); - - preg_match('/(\d+)(\.\d+){3}/', $process->getOutput(), $matches); - - if (! isset($matches[1])) { - continue; - } - - return $matches[1]; - } - - $this->error('Chrome version could not be detected.'); - - return false; - } }