Setting   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 4
dl 0
loc 73
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A issue() 0 4 1
A __construct() 0 6 1
A name() 0 4 1
A value() 0 4 1
A section() 0 4 1
A changeValue() 0 10 2
A setKey() 0 4 1
A setSection() 0 4 1
A setValue() 0 4 1
1
<?php
2
3
namespace Galileo\SettingBundle\Lib\Model;
4
5
use Galileo\SettingBundle\Lib\Model\Event\EventAggregateInterface;
6
use Galileo\SettingBundle\Lib\Model\Event\EventAggregateTrait;
7
use Galileo\SettingBundle\Lib\Model\ValueObject\Key;
8
use Galileo\SettingBundle\Lib\Model\ValueObject\Section;
9
use Galileo\SettingBundle\Lib\Model\ValueObject\Value;
10
11
class Setting implements EventAggregateInterface
12
{
13
    use EventAggregateTrait;
14
15
    protected $name;
16
    protected $value;
17
    protected $section;
18
19 7
    public static function issue(Key $name, Value $value, Section $section)
20
    {
21 7
        return new Setting($name, $value, $section);
22
    }
23
24 7
    public function __construct(Key $key, Value $value, Section $section)
25
    {
26 7
        $this->setKey($key);
27 7
        $this->setValue($value);
28 7
        $this->setSection($section);
29 7
    }
30
31 3
    public function name()
32
    {
33 3
        return $this->name;
34
    }
35
36 6
    public function value()
37
    {
38 6
        return $this->value;
39
    }
40
41 3
    public function section()
42
    {
43 3
        return $this->section;
44
    }
45
46
    /**
47
     * @param Value $value
48
     */
49 3
    public function changeValue(Value $value)
50
    {
51 3
        $internalValue = new Value($this->value);
52
53 3
        if ($value->equalsTo($internalValue)) {
54 1
            return;
55
        }
56
57 2
        $this->setValue($value);
58 2
    }
59
60
    /**
61
     * @param Key $key
62
     */
63 7
    private function setKey(Key $key)
64
    {
65 7
        $this->name = $key->key();
66 7
    }
67
68
    /**
69
     * @param Section $section
70
     */
71 7
    private function setSection(Section $section)
72
    {
73 7
        $this->section = $section->name();
74 7
    }
75
76
    /**
77
     * @param Value $value
78
     */
79 7
    private function setValue(Value $value)
80
    {
81 7
        $this->value = $value->value();
82 7
    }
83
}
84