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

PrePushProcessor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 31.71 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 5
dl 13
loc 41
rs 10
ccs 11
cts 11
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A process() 13 13 3
A configTools() 0 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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