PhpUnitConfigurator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 30
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A configure() 0 21 3
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use Composer\IO\IOInterface;
6
use PhpGitHooks\Module\Configuration\Domain\Enabled;
7
use PhpGitHooks\Module\Configuration\Domain\PhpUnit;
8
use PhpGitHooks\Module\Configuration\Domain\PhpUnitOptions;
9
use PhpGitHooks\Module\Configuration\Domain\PhpUnitRandomMode;
10
11
class PhpUnitConfigurator
12
{
13
    /**
14
     * @param IOInterface $io
15
     * @param PhpUnit     $phpUnit
16
     *
17
     * @return PhpUnit
18
     */
19 2
    public static function configure(IOInterface $io, PhpUnit $phpUnit)
20
    {
21
        /** @var PhpUnit $phpUnit */
22 2
        if (true === $phpUnit->isUndefined()) {
23 1
            $answer = $io->ask(HookQuestions::PHPUNIT_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
24
25 1
            $phpUnit = $phpUnit->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));
26
27 1
            if (true === $phpUnit->isEnabled()) {
28 1
                $randomAnswer = $io->ask(HookQuestions::PHPUNIT_RANDOM_MODE, HookQuestions::DEFAULT_TOOL_ANSWER);
29 1
                $optionsAnswer = $io->ask(HookQuestions::PHPUNIT_OPTIONS, null);
30
31 1
                $randomMode = new PhpUnitRandomMode(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($randomAnswer));
32 1
                $options = new PhpUnitOptions($optionsAnswer);
33
34 1
                $phpUnit = $phpUnit->setRandomModeAndOptions($randomMode, $options);
35
            }
36
        }
37
38 2
        return $phpUnit;
39
    }
40
}
41