Completed
Push — master ( 789220...9af5c5 )
by Jonathan
04:43
created

PasswordEncryptedValue   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 38
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A jsonSerialize() 0 4 1
A unserialize() 0 7 1
A getMac() 0 4 1
1
<?php
2
namespace Jsq\Cache;
3
4
class PasswordEncryptedValue extends EncryptedValue
5
{
6
    /** @var string */
7
    private $mac;
8
9
    /**
10
     * @param string $cipherText
11
     * @param string $method
12
     * @param string $iv
13
     * @param string $mac
14
     */
15 114
    public function __construct($cipherText, $method, $iv, $mac)
16
    {
17 114
        parent::__construct($cipherText, $method, $iv);
18 114
        $this->mac = $mac;
19 114
    }
20
21 3
    public function jsonSerialize()
22
    {
23 3
        return parent::jsonSerialize() + ['mac' => $this->mac];
24
    }
25
26 3
    public function unserialize($serialized)
27
    {
28 3
        parent::unserialize($serialized);
29
30 3
        $data = json_decode($serialized);
31 3
        $this->mac = $data->mac;
32 3
    }
33
34
    /**
35
     * @return string
36
     */
37 93
    public function getMac()
38
    {
39 93
        return $this->mac;
40
    }
41
}
42