Completed
Push — master ( efc44e...835840 )
by Pablo
02:59
created

PhpCs   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 103
Duplicated Lines 8.74 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 93.1%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 4
dl 9
loc 103
ccs 27
cts 29
cp 0.931
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A isEnabled() 0 4 1
A isUndefined() 0 4 1
A getStandard() 0 4 1
A getIgnore() 0 4 1
A addIgnore() 0 4 1
A setEnabled() 9 9 1
A addStandard() 0 9 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\Domain;
4
5
use PhpGitHooks\Module\Configuration\Model\ToolInterface;
6
7
class PhpCs implements ToolInterface
8
{
9
    /**
10
     * @var Undefined
11
     */
12
    private $undefined;
13
    /**
14
     * @var Enabled
15
     */
16
    private $enabled;
17
    /**
18
     * @var PhpCsStandard
19
     */
20
    private $standard;
21
    /**
22
     * @var Ignore
23
     */
24
    private $ignore;
25
26
    /**
27
     * PhpCs constructor.
28
     *
29
     * @param Undefined     $undefined
30
     * @param Enabled       $enabled
31
     * @param PhpCsStandard $standard
32
     * @param Ignore        $ignore
33
     */
34 6
    public function __construct(Undefined $undefined, Enabled $enabled, PhpCsStandard $standard, Ignore $ignore)
35
    {
36 6
        $this->undefined = $undefined;
37 6
        $this->enabled = $enabled;
38 6
        $this->standard = $standard;
39 6
        $this->ignore = $ignore;
40 6
    }
41
42
    /**
43
     * @return bool
44
     */
45 3
    public function isEnabled()
46
    {
47 3
        return $this->enabled->value();
48
    }
49
50
    /**
51
     * @return bool
52
     */
53 2
    public function isUndefined()
54
    {
55 2
        return $this->undefined->value();
56
    }
57
58
    /**
59
     * @return PhpCsStandard
60
     */
61 3
    public function getStandard()
62
    {
63 3
        return $this->standard;
64
    }
65
66
    /**
67
     * @return Ignore
68
     */
69 3
    public function getIgnore()
70
    {
71 3
        return $this->ignore;
72
    }
73
74
    /**
75
     * @return ToolInterface
76
     */
77 2 View Code Duplication
    public function setEnabled(Enabled $enabled)
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...
78
    {
79 2
        return new self(
80 2
            new Undefined(false),
81
            $enabled,
82 2
            new PhpCsStandard(null),
83 2
            new Ignore(null)
84
        );
85
    }
86
87
    /**
88
     * @param PhpCsStandard $standard
89
     *
90
     * @return PhpCs
91
     */
92 1
    public function addStandard(PhpCsStandard $standard)
93
    {
94 1
        return new self(
95 1
            $this->undefined,
96 1
            $this->enabled,
97
            $standard,
98 1
            $this->ignore
99
        );
100
    }
101
102
    /**
103
     * @param Ignore $ignore
104
     */
105 1
    public function addIgnore(Ignore $ignore)
106
    {
107 1
        $this->ignore = $ignore;
108 1
    }
109
}
110