Feature::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
3
namespace LaravelFeature\Domain\Model;
4
5
class Feature
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
6
{
7
    private $name;
8
    private $isEnabled;
9
10 33
    public static function fromNameAndStatus($name, $isEnabled)
11
    {
12 33
        $feature = new self($name, (bool) $isEnabled);
13 33
        return $feature;
14
    }
15
16 33
    private function __construct($name, $isEnabled)
17
    {
18 33
        $this->name = $name;
19 33
        $this->isEnabled = $isEnabled;
20 33
    }
21
22
    /**
23
     * @return string
24
     */
25 18
    public function getName()
26
    {
27 18
        return $this->name;
28
    }
29
30
    /**
31
     * @return bool
32
     */
33 15
    public function isEnabled()
34
    {
35 15
        return $this->isEnabled;
36
    }
37
38 3
    public function setNewName($newName)
39
    {
40 3
        $this->name = $newName;
41 3
    }
42
43 3
    public function enable()
44
    {
45 3
        $this->isEnabled = true;
46 3
    }
47
48 3
    public function disable()
49
    {
50 3
        $this->isEnabled = false;
51 3
    }
52
}
53