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

EnvelopeEncryptedValue::getSignature()   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 EnvelopeEncryptedValue extends EncryptedValue
5
{
6
    /** @var string */
7
    private $envelopeKey;
8
    /** @var string */
9
    private $signature;
10
11
    /**
12
     * @param string $cipherText
13
     * @param string $method
14
     * @param string $iv
15
     * @param string $key
16
     * @param string $signature
17
     */
18 114
    public function __construct($cipherText, $method, $iv, $key, $signature)
19
    {
20 114
        parent::__construct($cipherText, $method, $iv);
21 114
        $this->envelopeKey = $key;
22 114
        $this->signature = $signature;
23 114
    }
24
25 3
    public function jsonSerialize()
26
    {
27 3
        return parent::jsonSerialize() + [
28 3
            'key' => base64_encode($this->envelopeKey),
29 3
            'signature' => base64_encode($this->signature),
30 3
        ];
31
    }
32
33 3
    public function unserialize($serialized)
34
    {
35 3
        parent::unserialize($serialized);
36
37 3
        $data = json_decode($serialized);
38 3
        $this->envelopeKey = base64_decode($data->key);
39 3
        $this->signature = base64_decode($data->signature);
40 3
    }
41
42
    /**
43
     * @return string
44
     */
45 66
    public function getEnvelopeKey()
46
    {
47 66
        return $this->envelopeKey;
48
    }
49
50
    /**
51
     * @return string
52
     */
53 93
    public function getSignature()
54
    {
55 93
        return $this->signature;
56
    }
57
}
58