StopSeleniumCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
dl 7
loc 7
rs 9.4285
c 3
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace BeubiQA\Application\Command;
4
5
use BeubiQA\Application\Selenium\SeleniumHandler;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11 View Code Duplication
class StopSeleniumCommand extends Command
12
{
13
    /** @var SeleniumHandler  */
14
    protected $seleniumHandler;
15
16
    /**
17
     * @param SeleniumHandler $seleniumHandler
18
     */
19
    public function __construct(SeleniumHandler $seleniumHandler)
20
    {
21
        $this->seleniumHandler = $seleniumHandler;
22
        parent::__construct('start');
23
    }
24
25
    protected function configure()
26
    {
27
        $this
28
        ->setName('stop')
29
        ->addOption(
30
            'timeout',
31
            't',
32
            InputOption::VALUE_REQUIRED,
33
            'Set how much you are willing to wait until selenium server is stopped (in seconds)',
34
            30
35
        )
36
        ->addOption(
37
            'port',
38
            'p',
39
            InputOption::VALUE_REQUIRED,
40
            'Set how much you are willing to wait until selenium server is stopped (in seconds)',
41
            4444
42
        )
43
        ->setDescription('Stops selenium server');
44
    }
45
46
    /**
47
     * @param InputInterface  $input
48
     * @param OutputInterface $output
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        $this->setStopperOptionsFromInput($input);
53
        $this->seleniumHandler->stop();
54
        $output->writeln(PHP_EOL, true);
55
        $output->writeln("\nDone");
56
    }
57
58
    /**
59
     * @param InputInterface $input
60
     */
61
    private function setStopperOptionsFromInput(InputInterface $input)
62
    {
63
        $stopper = $this->seleniumHandler->getStopper();
64
        $stopper->getStopOptions()->setSeleniumPort($input->getOption('port'));
65
        $stopper->getResponseWaitter()->setTimeout($input->getOption('timeout'));
66
    }
67
}
68