Completed
Push — master ( 604a9a...cf79ad )
by Tony Karavasilev (Тони
18:44
created

EnvelopeData   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 17
c 1
b 0
f 0
dl 0
loc 75
ccs 0
cts 24
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __destruct() 0 2 1
A __construct() 0 16 5
A __toString() 0 6 1
1
<?php
2
3
/**
4
 * The digital envelope data object.
5
 */
6
7
namespace CryptoManana\DataStructures;
8
9
use \CryptoManana\Core\Abstractions\DataStructures\AbstractBasicStructure as BasicDataStructure;
10
11
/**
12
 * Class EnvelopeData - The digital envelope data object.
13
 *
14
 * @package CryptoManana\DataStructures
15
 *
16
 * @property string $key The encrypted secret key.
17
 * @property string $iv The encrypted initialization vector.
18
 * @property string $cipherData The encrypted message information.
19
 * @property string $authenticationTag The message authentication code (tag).
20
 */
21
class EnvelopeData extends BasicDataStructure
22
{
23
    /**
24
     * The concealed symmetric encryption secret key property storage.
25
     *
26
     * @var string The encrypted secret key.
27
     */
28
    protected $key = '';
29
30
    /**
31
     * The concealed symmetric encryption initialization vector property storage.
32
     *
33
     * @var string The encrypted initialization vector.
34
     */
35
    protected $iv = '';
36
37
    /**
38
     * The encrypted information property storage.
39
     *
40
     * @var string The encrypted data information.
41
     */
42
    protected $cipherData = '';
43
44
    /**
45
     * The message authentication code property storage.
46
     *
47
     * @var string The message authentication code (tag).
48
     */
49
    protected $authenticationTag = '';
50
51
    /**
52
     * Envelope constructor.
53
     *
54
     * @param string $encryptedKey The encrypted secret key.
55
     * @param string $encryptedIv The encrypted initialization vector.
56
     * @param string $encryptedData The encrypted message data information.
57
     * @param string $digestionTag The message authentication code (tag).
58
     */
59
    public function __construct($encryptedKey = '', $encryptedIv = '', $encryptedData = '', $digestionTag = '')
60
    {
61
        if (is_string($encryptedKey)) {
1 ignored issue
show
introduced by
The condition is_string($encryptedKey) is always true.
Loading history...
62
            $this->key = $encryptedKey;
63
        }
64
65
        if (is_string($encryptedIv)) {
1 ignored issue
show
introduced by
The condition is_string($encryptedIv) is always true.
Loading history...
66
            $this->iv = $encryptedIv;
67
        }
68
69
        if (is_string($encryptedData)) {
1 ignored issue
show
introduced by
The condition is_string($encryptedData) is always true.
Loading history...
70
            $this->cipherData = $encryptedData;
71
        }
72
73
        if (is_string($digestionTag)) {
1 ignored issue
show
introduced by
The condition is_string($digestionTag) is always true.
Loading history...
74
            $this->authenticationTag = $digestionTag;
75
        }
76
    }
77
78
    /**
79
     * Envelope destructor
80
     */
81
    public function __destruct()
82
    {
83
    }
84
85
    /**
86
     * The envelope string representation.
87
     *
88
     * @return string
89
     */
90
    public function __toString()
91
    {
92
        return 'key : ' . $this->key .
93
            ' | iv : ' . $this->iv .
94
            ' | encrypted : ' . $this->cipherData .
95
            ' | tag : ' . $this->authenticationTag;
96
    }
97
}
98