StepTimeLoggerController::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Bex\Behat\StepTimeLoggerExtension\Cli;
4
5
use Behat\Testwork\Cli\Controller;
6
use Bex\Behat\StepTimeLoggerExtension\ServiceContainer\Config;
7
use Symfony\Component\Console\Command\Command as SymfonyCommand;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
final class StepTimeLoggerController implements Controller
13
{
14
    /**
15
     * @var Config
16
     */
17
    private $config;
18
19
    /**
20
     * @param Config $config
21
     */
22
    public function __construct(Config $config)
23
    {
24
        $this->config = $config;    
25
    }
26
27
    /**
28
     * Configures command to be executable by the controller.
29
     *
30
     * @param SymfonyCommand $command
31
     */
32
    public function configure(SymfonyCommand $command)
33
    {
34
        $command->addOption('--log-step-times', null, InputOption::VALUE_NONE, 'Log step times');
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function execute(InputInterface $input, OutputInterface $output)
41
    {
42
        if ($input->getOption('log-step-times')) {
43
            $this->config->enableLogging();
44
        }
45
    }
46
}