CommandTesterWithValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 33
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A canExecuteCommand() 0 10 2
1
<?php
2
/**
3
 * Copyright (c) 2017 Constantin Galbenu <[email protected]>
4
 */
5
6
namespace Gica\Cqrs\Command\CommandTester;
7
8
9
use Gica\Cqrs\Command;
10
use Gica\Cqrs\Command\CommandTester;
11
use Gica\Cqrs\Command\CommandValidator;
12
13
class CommandTesterWithValidator implements CommandTester
14
{
15
16
    /**
17
     * @var CommandTester
18
     */
19
    private $commandTester;
20
    /**
21
     * @var CommandValidator
22
     */
23
    private $commandValidator;
24
25 3
    public function __construct(
26
        CommandTester $commandTester,
27
        CommandValidator $commandValidator
28
29
    )
30
    {
31 3
        $this->commandTester = $commandTester;
32 3
        $this->commandValidator = $commandValidator;
33 3
    }
34
35 3
    public function canExecuteCommand(Command $command): bool
36
    {
37 3
        $errors = $this->commandValidator->validateCommand($command);
38
39 3
        if (!empty($errors)) {
40 2
            return false;
41
        }
42
43 1
        return $this->commandTester->canExecuteCommand($command);
44
    }
45
}