Completed
Push — master ( 2c2534...8be39a )
by Pablo
02:42
created

Contract/Query/ConfigurationDataFinderHandler.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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();
0 ignored issues
show
The method getExecute() does not seem to exist on object<PhpGitHooks\Infrastructure\Hook\PrePush>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
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,
0 ignored issues
show
$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...
74 1
            $jsonLint,
0 ignored issues
show
$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...
75 1
            $phpLint,
0 ignored issues
show
$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...
76 1
            $phpMd,
77 1
            $phpCs,
78 1
            $phpCsFixer,
79 1
            $phpUnit,
80 1
            $phpUnitStrictCoverage,
81 1
            $phpUnitGuardCoverage,
82 1
            $commitMsg,
83 1
            $prePush,
0 ignored issues
show
$prePush is of type object<PhpGitHooks\Infrastructure\Hook\PrePush>, but the function expects a object<PhpGitHooks\Modul...uration\Domain\PrePush>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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