Value   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 54
ccs 20
cts 20
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A jsonSerialize() 0 7 1
A unserialize() 0 8 1
A getEnvelopeKey() 0 4 1
A getSignature() 0 4 1
1
<?php
2
namespace Jsq\Cache\EnvelopeEncryption;
3
4
use Jsq\Cache\EncryptedValue;
5
6
class Value extends EncryptedValue
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 36
    public function __construct($cipherText, $method, $iv, $key, $signature)
21
    {
22 36
        parent::__construct($cipherText, $method, $iv);
23 36
        $this->envelopeKey = $key;
24 36
        $this->signature = $signature;
25 36
    }
26
27 18
    public function jsonSerialize()
28
    {
29 18
        return parent::jsonSerialize() + [
30 18
            'key' => base64_encode($this->envelopeKey),
31 18
            'signature' => base64_encode($this->signature),
32 18
        ];
33
    }
34
35 18
    public function unserialize($serialized)
36
    {
37 18
        parent::unserialize($serialized);
38
39 18
        $data = json_decode($serialized);
40 18
        $this->envelopeKey = base64_decode($data->key);
41 18
        $this->signature = base64_decode($data->signature);
42 18
    }
43
44
    /**
45
     * @return string
46
     */
47 18
    public function getEnvelopeKey()
48
    {
49 18
        return $this->envelopeKey;
50
    }
51
52
    /**
53
     * @return string
54
     */
55 18
    public function getSignature()
56
    {
57 18
        return $this->signature;
58
    }
59
}
60