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

PhpCsFixer   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 124
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 4
dl 0
loc 124
ccs 36
cts 39
cp 0.9231
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A isEnabled() 0 4 1
A isUndefined() 0 4 1
A getLevels() 0 4 1
A getOptions() 0 4 1
A setOptions() 0 9 1
A setEnabled() 0 17 2
A addLevels() 0 9 1
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Domain;
4
5
use PhpGitHooks\Module\Configuration\Model\ToolInterface;
6
7
class PhpCsFixer implements ToolInterface
8
{
9
    /**
10
     * @var Undefined
11
     */
12
    private $undefined;
13
    /**
14
     * @var Enabled
15
     */
16
    private $enabled;
17
    /**
18
     * @var PhpCsFixerLevels
19
     */
20
    private $levels;
21
    /**
22
     * @var PhpCsFixerOptions
23
     */
24
    private $options;
25
26
    /**
27
     * PhpCsFixer constructor.
28
     *
29
     * @param Undefined         $undefined
30
     * @param Enabled           $enabled
31
     * @param PhpCsFixerLevels  $levels
32
     * @param PhpCsFixerOptions $options
33
     */
34 6
    public function __construct(
35
        Undefined $undefined,
36
        Enabled $enabled,
37
        PhpCsFixerLevels $levels,
38
        PhpCsFixerOptions $options
39
    ) {
40 6
        $this->undefined = $undefined;
41 6
        $this->enabled = $enabled;
42 6
        $this->levels = $levels;
43 6
        $this->options = $options;
44 6
    }
45
46
    /**
47
     * @return bool
48
     */
49 3
    public function isEnabled()
50
    {
51 3
        return $this->enabled->value();
52
    }
53
54
    /**
55
     * @return bool
56
     */
57 2
    public function isUndefined()
58
    {
59 2
        return $this->undefined->value();
60
    }
61
62
    /**
63
     * @return PhpCsFixerLevels
64
     */
65 3
    public function getLevels()
66
    {
67 3
        return $this->levels;
68
    }
69
70
    /**
71
     * @param Enabled $enabled
72
     *
73
     * @return PhpCsFixer
74
     */
75 2
    public function setEnabled(Enabled $enabled)
76
    {
77 2
        $levels = false === $enabled->value() ?
78 1
            new PhpCsFixerLevels(
79 1
                new Level(false),
80 1
                new Level(false),
81 1
                new Level(false),
82 1
                new Level(false)
83 2
            ) : $this->levels;
84
85 2
        return new self(
86 2
            new Undefined(false),
87
            $enabled,
88
            $levels,
89 2
            $this->options
90
        );
91
    }
92
93
    /**
94
     * @param PhpCsFixerLevels $levels
95
     *
96
     * @return PhpCsFixer
97
     */
98 1
    public function addLevels(PhpCsFixerLevels $levels)
99
    {
100 1
        return new self(
101 1
            $this->undefined,
102 1
            $this->enabled,
103
            $levels,
104 1
            $this->options
105
        );
106
    }
107
108
    /**
109
     * @return PhpCsFixerOptions
110
     */
111 3
    public function getOptions()
112
    {
113 3
        return $this->options;
114
    }
115
116
    /**
117
     * @param PhpCsFixerOptions $options
118
     *
119
     * @return PhpCsFixer
120
     */
121 1
    public function setOptions(PhpCsFixerOptions $options)
122
    {
123 1
        return new self(
124 1
            $this->undefined,
125 1
            $this->enabled,
126 1
            $this->levels,
127 1
            $options
128
        );
129
    }
130
}
131