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

PhpUnitGuardCoverage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 81
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 95.24%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 81
loc 81
ccs 20
cts 21
cp 0.9524
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A isEnabled() 4 4 1
A isUndefined() 4 4 1
A getWarningMessage() 4 4 1
A setWarningMessage() 8 8 1
A setEnabled() 8 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\Domain;
4
5
use PhpGitHooks\Module\Configuration\Model\ToolInterface;
6
7 View Code Duplication
class PhpUnitGuardCoverage implements ToolInterface
0 ignored issues
show
Duplication introduced by
This class 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...
8
{
9
    /**
10
     * @var Undefined
11
     */
12
    private $undefined;
13
    /**
14
     * @var Enabled
15
     */
16
    private $enabled;
17
    /**
18
     * @var Message
19
     */
20
    private $warningMessage;
21
22
    /**
23
     * PhpUnitGuardCoverage constructor.
24
     *
25
     * @param Undefined $undefined
26
     * @param Enabled   $enabled
27
     * @param Message   $warningMessage
28
     */
29 6
    public function __construct(Undefined $undefined, Enabled $enabled, Message $warningMessage)
30
    {
31 6
        $this->undefined = $undefined;
32 6
        $this->enabled = $enabled;
33 6
        $this->warningMessage = $warningMessage;
34 6
    }
35
36
    /**
37
     * @return bool
38
     */
39 3
    public function isEnabled()
40
    {
41 3
        return $this->enabled->value();
42
    }
43
44
    /**
45
     * @return bool
46
     */
47 2
    public function isUndefined()
48
    {
49 2
        return $this->undefined->value();
50
    }
51
52
    /**
53
     * @return Message
54
     */
55 3
    public function getWarningMessage()
56
    {
57 3
        return $this->warningMessage;
58
    }
59
60
    /**
61
     * @param Enabled $enabled
62
     *
63
     * @return PhpUnitGuardCoverage
64
     */
65 2
    public function setEnabled(Enabled $enabled)
66
    {
67 2
        return new self(
68 2
            new Undefined(false),
69
            $enabled,
70 2
            $this->warningMessage
71
        );
72
    }
73
74
    /**
75
     * @param Message $message
76
     *
77
     * @return PhpUnitGuardCoverage
78
     */
79 1
    public function setWarningMessage(Message $message)
80
    {
81 1
        return new self(
82 1
            $this->undefined,
83 1
            $this->enabled,
84 1
            $message
85
        );
86
    }
87
}
88