Completed
Push — master ( 982f0c...377cb6 )
by Kamil
05:13 queued 02:16
created

Section::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Galileo\SettingBundle\Lib\Model\ValueObject;
4
5
use Galileo\SettingBundle\Lib\Model\Exceptions\GuardException;
6
use Galileo\SettingBundle\Lib\Model\Specification\AlphaNumericSpecification;
7
8
class Section
9
{
10
    const EMPTY_SECTION = '___empty_section___';
11
12
    private $name;
13
14
    /**
15
     * @param string $name
16
     *
17
     * @throws GuardException
18
     */
19
    public function __construct($name)
20
    {
21
        $this->guard($name);
22
        $this->setName($name);
23
    }
24
25
    public static function blank()
26
    {
27
        return new Section(Section::EMPTY_SECTION);
28
    }
29
30
    public function name()
31
    {
32
        return $this->name;
33
    }
34
35
    /**
36
     * @param $name
37
     */
38
    private function setName($name)
39
    {
40
        $this->name = $name;
41
    }
42
43
    /**
44
     * @param $name
45
     */
46
    private function guard($name)
47
    {
48
        $alphaNumericSpecification = new AlphaNumericSpecification();
49
        $alphaNumericSpecification->guard($name);
50
    }
51
}
52