Passed
Pull Request — master (#6)
by Chris
05:44
created

Key   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 38
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getIdentifier() 0 4 1
A getKeyInfo() 0 4 1
1
<?php
2
3
namespace Carnage\EncryptedColumn\ValueObject;
4
5
use ParagonIE\Halite\Util;
6
7
final class Key
8
{
9
    /**
10
     * @var KeyIdentity
11
     */
12
    private $identifier;
13
14
    /**
15
     * @var string
16
     */
17
    private $keyInfo;
18
19
    /**
20
     * Key constructor.
21
     * @param $keyInfo
22
     */
23 6
    public function __construct(string $keyInfo)
24
    {
25 6
        $this->identifier = new KeyIdentity(Util::safeSubstr(hash('sha256', $keyInfo), 0, 8));
26 6
        $this->keyInfo = $keyInfo;
27 6
    }
28
29
    /**
30
     * @return KeyIdentity
31
     */
32 7
    public function getIdentifier(): KeyIdentity
33
    {
34 7
        return $this->identifier;
35
    }
36
37
    /**
38
     * @return string
39
     */
40 7
    public function getKeyInfo(): string
41
    {
42 7
        return $this->keyInfo;
43
    }
44
}
45