Completed
Push — master ( 71abfe...238f74 )
by Pablo
05:15
created

ConfigurationDataFinder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use Bruli\EventBusBundle\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\PhpUnitGuardCoverage;
14
use PhpGitHooks\Module\Configuration\Domain\PhpUnitStrictCoverage;
15
use PhpGitHooks\Module\Configuration\Domain\PreCommit;
16
use PhpGitHooks\Module\Configuration\Domain\PrePush;
17
use PhpGitHooks\Module\Configuration\Model\ConfigurationFileReaderInterface;
18
19
class ConfigurationDataFinder implements QueryInterface
20
{
21
    /**
22
     * @var ConfigurationFileReaderInterface
23
     */
24
    private $configurationFileReader;
25
26
    /**
27
     * ConfigurationDataFinder constructor.
28
     *
29
     * @param ConfigurationFileReaderInterface $configurationFileReader
30
     */
31 1
    public function __construct(ConfigurationFileReaderInterface $configurationFileReader)
32
    {
33 1
        $this->configurationFileReader = $configurationFileReader;
34 1
    }
35
36
    /**
37
     * @return ConfigurationDataResponse
38
     */
39 1
    public function find()
40
    {
41 1
        $data = $this->configurationFileReader->getData();
42
43 1
        return $this->getConfigurationDataResponse($data);
44
    }
45
46 1
    private function getConfigurationDataResponse(Config $data)
47
    {
48
        /** @var PreCommit $preCommit */
49 1
        $preCommit = $data->getPreCommit();
50
        /** @var CommitMsg $commitMsg */
51 1
        $commitMsg = $data->getCommitMsg();
52 1
        $tools = $preCommit->getExecute()->execute();
53
        /** @var PrePush $prePush */
54 1
        $prePush = $data->getPrePush();
55 1
        $prePushTools = $prePush->getExecute()->execute();
56
57 1
        $composer = $tools[0];
58 1
        $jsonLint = $tools[1];
59 1
        $phpLint = $tools[2];
60
        /** @var PhpMd $phpMd */
61 1
        $phpMd = $tools[3];
62
        /** @var PhpCs $phpCs */
63 1
        $phpCs = $tools[4];
64
        /** @var PhpCsFixer $phpCsFixer */
65 1
        $phpCsFixer = $tools[5];
66
        /** @var PhpUnit $phpUnit */
67 1
        $phpUnit = $tools[6];
68
        /** @var PhpUnitStrictCoverage $phpUnitStrictCoverage */
69 1
        $phpUnitStrictCoverage = $tools[7];
70
        /** @var PhpUnitGuardCoverage $phpUnitGuardCoverage */
71 1
        $phpUnitGuardCoverage = $tools[8];
72
        /** @var PhpUnit $prePushPhpUnit */
73 1
        $prePushPhpUnit = $prePushTools[0];
74
        /** @var PhpUnitStrictCoverage $prePushStrictCoverage */
75 1
        $prePushStrictCoverage = $prePushTools[1];
76
        /** @var PhpUnitGuardCoverage $prePushGuardCoverage */
77 1
        $prePushGuardCoverage = $prePushTools[2];
78
79 1
        return ConfigurationDataResponseFactory::build(
80
            $preCommit,
81
            $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...
82
            $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...
83
            $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...
84
            $phpMd,
85
            $phpCs,
86
            $phpCsFixer,
87
            $phpUnit,
88
            $phpUnitStrictCoverage,
89
            $phpUnitGuardCoverage,
90
            $commitMsg,
91
            $prePush,
92
            $prePushPhpUnit,
93
            $prePushStrictCoverage,
94 1
            $prePushGuardCoverage
95
        );
96
    }
97
}
98