Key::setKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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