Execute   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 46
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 4 1
A disableTools() 0 10 2
A __construct() 0 9 3
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Domain;
4
5
use PhpGitHooks\Module\Configuration\Contract\Exception\InvalidToolInterfaceException;
6
use PhpGitHooks\Module\Configuration\Model\ExecuteInterface;
7
use PhpGitHooks\Module\Configuration\Model\ToolInterface;
8
9
class Execute implements ExecuteInterface
10
{
11
    /**
12
     * @var ToolInterface[]
13
     */
14
    private $tools;
15
16
    /**
17
     * Execute constructor.
18
     *
19
     * @param ToolInterface[] $tools
20
     *
21
     * @throws InvalidToolInterfaceException
22
     */
23 6
    public function __construct(array $tools)
24
    {
25 6
        foreach ($tools as $tool) {
26 6
            if (!$tool instanceof ToolInterface) {
27
                throw new InvalidToolInterfaceException($tool);
28
            }
29
        }
30 6
        $this->tools = $tools;
31 6
    }
32
33
    /**
34
     * @return ToolInterface[]
35
     */
36 4
    public function execute()
37
    {
38 4
        return $this->tools;
39
    }
40
41
    /**
42
     * @return Execute
43
     */
44 1
    public function disableTools()
45
    {
46 1
        $tools = [];
47
48 1
        foreach ($this->tools as $key => $tool) {
49 1
            $tools[$key] = $tool->setEnabled(new Enabled(false));
50
        }
51
52 1
        return new self($tools);
53
    }
54
}
55