ShowSeleniumCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 48
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A configure() 0 20 1
A execute() 0 9 1
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
class ShowSeleniumCommand extends Command
12
{
13
    /** @var SeleniumHandler  */
14
    protected $seleniumHandler;
15
16
    public function __construct(SeleniumHandler $seleniumHandler)
17
    {
18
        $this->seleniumHandler = $seleniumHandler;
19
        parent::__construct('start');
20
    }
21
22
    protected function configure()
23
    {
24
        $this
25
        ->setName('show')
26
        ->setDescription('Displays selenium server log (tails the log file)')
27
        ->addOption(
28
            'log-location',
29
            null,
30
            InputOption::VALUE_REQUIRED,
31
            'Set the location of the selenium.log file',
32
            'selenium.log'
33
        )
34
        ->addOption(
35
            'follow',
36
            'f',
37
            InputOption::VALUE_OPTIONAL,
38
            'Follow selenium log. You may choose a specific level to follow. E.g. --follow ERROR ',
39
            'INFO'
40
        );
41
    }
42
43
    /**
44
     * @param InputInterface  $input
45
     * @param OutputInterface $output
46
     *
47
     * @throws \RuntimeException
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output)
50
    {
51
        $options = [];
52
        $options['follow'] = $input->getOption('follow');
53
        $options['log-location'] = $input->getOption('log-location');
54
55
        $output->writeln('Displaying '.$options['log-location'].' file:'.PHP_EOL);
56
        $this->seleniumHandler->watch($options);
57
    }
58
}
59