Completed
Push — master ( c39607...87b4fe )
by Jonathan
09:41
created

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