Completed
Push — master ( 879230...0afc29 )
by Pablo
05:15
created

PhpCsFixer::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 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 2
            $enabled,
88 2
            $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 1
            $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