WebDriver::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 13
nop 0
1
<?php
2
3
namespace Magium\Cli\Command;
4
5
use Magium\InvalidInstructionException;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class WebDriver extends Command
13
{
14
15
    protected function configure()
16
    {
17
        $this->setName('magium:webdriver');
18
        $this->setDescription('Configures the WebDriver settings');
19
        $this->addOption(
20
            'url',
21
            null,
22
            InputArgument::OPTIONAL,
23
            'The URL to connect to'
24
        );
25
        $this->addOption(
26
            'capability',
27
            null,
28
            InputArgument::OPTIONAL,
29
            'The browser capability (chrome, firefox, phantomjs, etc.)'
30
        );
31
    }
32
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $command = $this->getApplication()->find('element:set');
36
37
        if (!$input->getOption('url') && !$input->getOption('capability')) {
38
            throw new InvalidInstructionException('url and/or capability required.  Neither found.');
39
        }
40
41
        $url = $input->getOption('url');
42 View Code Duplication
        if ($url) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
            $arguments = [
44
                'command' => $command->getName(),
45
                'class'    => 'Magium\\TestCaseConfiguration',
46
                'property'  => 'webDriverRemote',
47
                'value'     => $url
48
            ];
49
            $webDriverInput = new ArrayInput($arguments);
50
            $command->run($webDriverInput, $output);
51
        }
52
53
        $capability = $input->getOption('capability');
54 View Code Duplication
        if ($capability) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
            $arguments = [
56
                'command' => $command->getName(),
57
                'class'    => 'Magium\\TestCaseConfiguration',
58
                'property'  => 'capabilities',
59
                'value'     => $capability
60
            ];
61
            $webDriverInput = new ArrayInput($arguments);
62
            $command->run($webDriverInput, $output);
63
        }
64
    }
65
66
}