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

Key   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 40
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fromString() 0 4 1
A key() 0 4 1
A guard() 0 5 1
A setKey() 0 4 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
    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