StartCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 5
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 14 2
1
<?php
2
namespace Peridot\WebDriverManager\Console;
3
4
use Symfony\Component\Console\Input\ArrayInput;
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
/**
10
 * StartCommand is used to start Selenium Server in the foreground. If drivers and binaries
11
 * are not up to date, the start command will update before starting.
12
 *
13
 * @package Peridot\WebDriverManager\Console
14
 */
15
class StartCommand extends AbstractManagerCommand
16
{
17
    protected function configure()
18
    {
19
        $this
20
            ->setName('start')
21
            ->setDescription('Start Selenium Server')
22
            ->addArgument(
23
                'port',
24
                InputArgument::OPTIONAL,
25
                'The port you want to start Selenium Server on'
26
            );
27
    }
28
29
    /**
30
     * @param InputInterface $input
31
     * @param OutputInterface $output
32
     * @return int|null
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $port = $input->getArgument('port');
37
        if (! $port) {
38
            $port = 4444;
39
        }
40
41
        $update = $this->getApplication()->find('update');
42
        $update->run(new ArrayInput(['command' => 'update']), $output);
43
44
        $output->writeln('<info>Starting Selenium Server...</info>');
45
        $this->manager->startInForeground($port);
46
        return 0;
47
    }
48
} 
49