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

EnvelopeData::__construct()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
ccs 0
cts 13
cp 0
rs 9.6111
cc 5
nc 16
nop 4
crap 30
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