Value::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
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\PasswordEncryption;
3
4
use Jsq\Cache\EncryptedValue;
5
6
class Value extends EncryptedValue
7
{
8
    /** @var string */
9
    private $mac;
10
11
    /**
12
     * @param string $cipherText
13
     * @param string $method
14
     * @param string $iv
15
     * @param string $mac
16
     */
17 36
    public function __construct($cipherText, $method, $iv, $mac)
18
    {
19 36
        parent::__construct($cipherText, $method, $iv);
20 36
        $this->mac = $mac;
21 36
    }
22
23 18
    public function jsonSerialize()
24
    {
25 18
        return parent::jsonSerialize() + ['mac' => $this->mac];
26
    }
27
28 18
    public function unserialize($serialized)
29
    {
30 18
        parent::unserialize($serialized);
31
32 18
        $data = json_decode($serialized);
33 18
        $this->mac = $data->mac;
34 18
    }
35
36
    /**
37
     * @return string
38
     */
39 18
    public function getMac()
40
    {
41 18
        return $this->mac;
42
    }
43
}
44