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, |
|
|
|
|
82
|
|
|
$jsonLint, |
|
|
|
|
83
|
|
|
$phpLint, |
|
|
|
|
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
|
|
|
|
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.