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

PasswordEncryptedValue::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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