1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpGitHooks\Module\Configuration\Contract\Query; |
4
|
|
|
|
5
|
|
|
use Bruli\EventBusBundle\QueryBus\QueryHandlerInterface; |
6
|
|
|
use Bruli\EventBusBundle\QueryBus\QueryInterface; |
7
|
|
|
use PhpGitHooks\Infrastructure\Hook\PrePush; |
8
|
|
|
use PhpGitHooks\Module\Configuration\Contract\Response\ConfigurationDataResponse; |
9
|
|
|
use PhpGitHooks\Module\Configuration\Domain\CommitMsg; |
10
|
|
|
use PhpGitHooks\Module\Configuration\Domain\Config; |
11
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PhpCs; |
12
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PhpCsFixer; |
13
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PhpMd; |
14
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PhpUnit; |
15
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PhpUnitGuardCoverage; |
16
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PhpUnitStrictCoverage; |
17
|
|
|
use PhpGitHooks\Module\Configuration\Domain\PreCommit; |
18
|
|
|
use PhpGitHooks\Module\Configuration\Model\ConfigurationFileReaderInterface; |
19
|
|
|
use PhpGitHooks\Module\Configuration\Service\ConfigurationDataResponseFactory; |
20
|
|
|
|
21
|
|
|
class ConfigurationDataFinderHandler implements QueryHandlerInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var ConfigurationFileReaderInterface |
25
|
|
|
*/ |
26
|
|
|
private $configurationFileReader; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* ConfigurationDataFinder constructor. |
30
|
|
|
* |
31
|
|
|
* @param ConfigurationFileReaderInterface $configurationFileReader |
32
|
|
|
*/ |
33
|
1 |
|
public function __construct(ConfigurationFileReaderInterface $configurationFileReader) |
34
|
|
|
{ |
35
|
1 |
|
$this->configurationFileReader = $configurationFileReader; |
36
|
1 |
|
} |
37
|
|
|
|
38
|
1 |
|
private function getConfigurationDataResponse(Config $data) |
39
|
|
|
{ |
40
|
|
|
/** @var PreCommit $preCommit */ |
41
|
1 |
|
$preCommit = $data->getPreCommit(); |
42
|
|
|
/** @var CommitMsg $commitMsg */ |
43
|
1 |
|
$commitMsg = $data->getCommitMsg(); |
44
|
1 |
|
$tools = $preCommit->getExecute()->execute(); |
45
|
|
|
/** @var PrePush $prePush */ |
46
|
1 |
|
$prePush = $data->getPrePush(); |
47
|
1 |
|
$prePushTools = $prePush->getExecute()->execute(); |
48
|
|
|
|
49
|
1 |
|
$composer = $tools[0]; |
50
|
1 |
|
$jsonLint = $tools[1]; |
51
|
1 |
|
$phpLint = $tools[2]; |
52
|
|
|
/** @var PhpMd $phpMd */ |
53
|
1 |
|
$phpMd = $tools[3]; |
54
|
|
|
/** @var PhpCs $phpCs */ |
55
|
1 |
|
$phpCs = $tools[4]; |
56
|
|
|
/** @var PhpCsFixer $phpCsFixer */ |
57
|
1 |
|
$phpCsFixer = $tools[5]; |
58
|
|
|
/** @var PhpUnit $phpUnit */ |
59
|
1 |
|
$phpUnit = $tools[6]; |
60
|
|
|
/** @var PhpUnitStrictCoverage $phpUnitStrictCoverage */ |
61
|
1 |
|
$phpUnitStrictCoverage = $tools[7]; |
62
|
|
|
/** @var PhpUnitGuardCoverage $phpUnitGuardCoverage */ |
63
|
1 |
|
$phpUnitGuardCoverage = $tools[8]; |
64
|
|
|
/** @var PhpUnit $prePushPhpUnit */ |
65
|
1 |
|
$prePushPhpUnit = $prePushTools[0]; |
66
|
|
|
/** @var PhpUnitStrictCoverage $prePushStrictCoverage */ |
67
|
1 |
|
$prePushStrictCoverage = $prePushTools[1]; |
68
|
|
|
/** @var PhpUnitGuardCoverage $prePushGuardCoverage */ |
69
|
1 |
|
$prePushGuardCoverage = $prePushTools[2]; |
70
|
|
|
|
71
|
1 |
|
return ConfigurationDataResponseFactory::build( |
72
|
1 |
|
$preCommit, |
73
|
1 |
|
$composer, |
74
|
1 |
|
$jsonLint, |
75
|
1 |
|
$phpLint, |
76
|
1 |
|
$phpMd, |
77
|
1 |
|
$phpCs, |
78
|
1 |
|
$phpCsFixer, |
79
|
1 |
|
$phpUnit, |
80
|
1 |
|
$phpUnitStrictCoverage, |
81
|
1 |
|
$phpUnitGuardCoverage, |
82
|
1 |
|
$commitMsg, |
83
|
1 |
|
$prePush, |
|
|
|
|
84
|
1 |
|
$prePushPhpUnit, |
85
|
1 |
|
$prePushStrictCoverage, |
86
|
1 |
|
$prePushGuardCoverage |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param QueryInterface $query |
92
|
|
|
* |
93
|
|
|
* @return ConfigurationDataResponse |
94
|
|
|
*/ |
95
|
1 |
|
public function handle(QueryInterface $query) |
96
|
|
|
{ |
97
|
1 |
|
$data = $this->configurationFileReader->getData(); |
98
|
|
|
|
99
|
1 |
|
return $this->getConfigurationDataResponse($data); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: