Completed
Push — master ( 30874d...ed8031 )
by Pablo
02:56
created

ConfigurationDataFinder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 1 Features 1
Metric Value
wmc 3
c 9
b 1
f 1
lcom 1
cbo 6
dl 0
loc 73
ccs 37
cts 37
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A find() 0 6 1
B getConfigurationDataResponse() 0 45 1
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use PhpGitHooks\Infrastructure\CommandBus\QueryBus\QueryInterface;
6
use PhpGitHooks\Module\Configuration\Contract\Response\ConfigurationDataResponse;
7
use PhpGitHooks\Module\Configuration\Domain\CommitMsg;
8
use PhpGitHooks\Module\Configuration\Domain\Config;
9
use PhpGitHooks\Module\Configuration\Domain\PhpCs;
10
use PhpGitHooks\Module\Configuration\Domain\PhpCsFixer;
11
use PhpGitHooks\Module\Configuration\Domain\PhpMd;
12
use PhpGitHooks\Module\Configuration\Domain\PhpUnit;
13
use PhpGitHooks\Module\Configuration\Domain\PhpUnitStrictCoverage;
14
use PhpGitHooks\Module\Configuration\Domain\PreCommit;
15
use PhpGitHooks\Module\Configuration\Domain\PrePush;
16
use PhpGitHooks\Module\Configuration\Model\ConfigurationFileReaderInterface;
17
18
class ConfigurationDataFinder implements QueryInterface
19
{
20
    /**
21
     * @var ConfigurationFileReaderInterface
22
     */
23
    private $configurationFileReader;
24
25
    /**
26
     * ConfigurationDataFinder constructor.
27
     *
28
     * @param ConfigurationFileReaderInterface $configurationFileReader
29
     */
30 1
    public function __construct(ConfigurationFileReaderInterface $configurationFileReader)
31
    {
32 1
        $this->configurationFileReader = $configurationFileReader;
33 1
    }
34
35
    /**
36
     * @return ConfigurationDataResponse
37
     */
38 1
    public function find()
39
    {
40 1
        $data = $this->configurationFileReader->getData();
41
42 1
        return $this->getConfigurationDataResponse($data);
43 1
    }
44
45 1
    private function getConfigurationDataResponse(Config $data)
46
    {
47
        /** @var PreCommit $preCommit */
48 1
        $preCommit = $data->getPreCommit();
49
        /** @var CommitMsg $commitMsg */
50 1
        $commitMsg = $data->getCommitMsg();
51 1
        $tools = $preCommit->getExecute()->execute();
52
        /** @var PrePush $prePush */
53 1
        $prePush = $data->getPrePush();
54 1
        $prePushTools = $prePush->getExecute()->execute();
55
56 1
        $composer = $tools[0];
57 1
        $jsonLint = $tools[1];
58 1
        $phpLint = $tools[2];
59
        /** @var PhpMd $phpMd */
60 1
        $phpMd = $tools[3];
61
        /** @var PhpCs $phpCs */
62 1
        $phpCs = $tools[4];
63
        /** @var PhpCsFixer $phpCsFixer */
64 1
        $phpCsFixer = $tools[5];
65
        /** @var PhpUnit $phpUnit */
66 1
        $phpUnit = $tools[6];
67
        /** @var PhpUnitStrictCoverage $phpUnitStrictCoverage */
68 1
        $phpUnitStrictCoverage = $tools[7];
69
        /** @var PhpUnit $prePushPhpUnit */
70 1
        $prePushPhpUnit = $prePushTools[0];
71
        /** @var PhpUnitStrictCoverage $prePushStrictCoverage */
72 1
        $prePushStrictCoverage = $prePushTools[1];
73
74 1
        return ConfigurationDataResponseFactory::build(
75 1
            $preCommit,
76 1
            $composer,
0 ignored issues
show
Compatibility introduced by
$composer of type object<PhpGitHooks\Modul...on\Model\ToolInterface> is not a sub-type of object<PhpGitHooks\Modul...ration\Domain\Composer>. It seems like you assume a concrete implementation of the interface PhpGitHooks\Module\Confi...ion\Model\ToolInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
77 1
            $jsonLint,
0 ignored issues
show
Compatibility introduced by
$jsonLint of type object<PhpGitHooks\Modul...on\Model\ToolInterface> is not a sub-type of object<PhpGitHooks\Modul...ration\Domain\JsonLint>. It seems like you assume a concrete implementation of the interface PhpGitHooks\Module\Confi...ion\Model\ToolInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
78 1
            $phpLint,
0 ignored issues
show
Compatibility introduced by
$phpLint of type object<PhpGitHooks\Modul...on\Model\ToolInterface> is not a sub-type of object<PhpGitHooks\Modul...uration\Domain\PhpLint>. It seems like you assume a concrete implementation of the interface PhpGitHooks\Module\Confi...ion\Model\ToolInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
79 1
            $phpMd,
80 1
            $phpCs,
81 1
            $phpCsFixer,
82 1
            $phpUnit,
83 1
            $phpUnitStrictCoverage,
84 1
            $commitMsg,
85 1
            $prePush,
86 1
            $prePushPhpUnit,
87
            $prePushStrictCoverage
88 1
        );
89
    }
90
}
91