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

Key::key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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 Key
9
{
10
    private $key;
11
12
    /**
13
     * @throws GuardException
14
     */
15
    public function __construct($key)
16
    {
17
        $this->guard($key);
18
        $this->setKey($key);
19
    }
20
21
    public static function fromString($keyName)
22
    {
23
        return new Key($keyName);
24
    }
25
26
    public function key()
27
    {
28
        return $this->key;
29
    }
30
31
    /**
32
     * @param $key
33
     */
34
    private function guard($key)
35
    {
36
        $alphaNumericSpecification = new AlphaNumericSpecification();
37
        $alphaNumericSpecification->guard($key);
38
    }
39
40
    /**
41
     * @param $key
42
     */
43
    private function setKey($key)
44
    {
45
        $this->key = $key;
46
    }
47
}
48