Completed
Branch module_structure (3116d9)
by Pablo
02:56
created

PrePushProcessor::process()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 13
loc 13
rs 9.4285
ccs 7
cts 7
cp 1
cc 3
eloc 7
nc 4
nop 2
crap 3
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use Composer\IO\IOInterface;
6
use PhpGitHooks\Module\Configuration\Domain\Execute;
7
use PhpGitHooks\Module\Configuration\Domain\PrePush;
8
use PhpGitHooks\Module\Configuration\Model\ExecuteInterface;
9
10
class PrePushProcessor
11
{
12
    /**
13
     * @var IOInterface
14
     */
15
    private $input;
16
17
    /**
18
     * @param PrePush     $prePushData
19
     * @param IOInterface $input
20
     *
21
     * @return PrePush
22
     */
23 2 View Code Duplication
    public function process(PrePush $prePushData, IOInterface $input)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25 2
        $this->input = $input;
26 2
        if (true === $prePushData->isUndefined()) {
27 1
            $prePushData = PrePushConfigurator::configure($this->input, $prePushData);
28
        }
29
30 2
        if (true === $prePushData->isEnabled()) {
31 2
            $prePushData = $prePushData->setExecute($this->configTools($prePushData->getExecute()));
32
        }
33
34 2
        return $prePushData;
35
    }
36
37
    /**
38
     * @param ExecuteInterface $execute
39
     *
40
     * @return Execute
41
     */
42 2
    protected function configTools(ExecuteInterface $execute)
43
    {
44 2
        $tools = $execute->execute();
45
46 2
        $tools[0] = PhpUnitConfigurator::configure($this->input, $tools[0]);
0 ignored issues
show
Compatibility introduced by
$tools[0] of type object<PhpGitHooks\Modul...on\Model\ToolInterface> is not a sub-type of object<PhpGitHooks\Modul...uration\Domain\PhpUnit>. 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...
47
48 2
        return new  Execute($tools);
49
    }
50
}
51