Passed
Push — master ( 2935f9...5bf936 )
by Tony Karavasilev (Тони
07:06
created

EncryptionLayer::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * The encryption layer configuration object.
5
 */
6
7
namespace CryptoManana\DataStructures;
8
9
use CryptoManana\Core\Abstractions\DataStructures\AbstractBasicStructure as BasicDataStructure;
10
11
/**
12
 * Class EncryptionLayer - The encryption layer configuration object.
13
 *
14
 * @package CryptoManana\DataStructures
15
 *
16
 * @property string $cipher The cipher object name.
17
 * @property string $key The secret key.
18
 * @property string $iv The initialization vector.
19
 * @property string $mode The block mode.
20
 * @property int $padding The padding standard.
21
 * @property int $format The output cipher format.
22
 */
23
class EncryptionLayer extends BasicDataStructure
24
{
25
    /**
26
     * The symmetric encryption cipher object name property storage.
27
     *
28
     * @var string The cipher object name.
29
     */
30
    protected $cipher = '';
31
32
    /**
33
     * The symmetric encryption secret key property storage.
34
     *
35
     * @var string The secret key.
36
     */
37
    protected $key = '';
38
39
    /**
40
     * The symmetric encryption initialization vector property storage.
41
     *
42
     * @var string The initialization vector.
43
     */
44
    protected $iv = '';
45
46
    /**
47
     * The symmetric encryption block mode property storage.
48
     *
49
     * @var string The block mode.
50
     */
51
    protected $mode = '';
52
53
    /**
54
     * The symmetric encryption padding standard property storage.
55
     *
56
     * @var int The padding standard.
57
     */
58
    protected $padding = 0;
59
60
    /**
61
     * The symmetric encryption output cipher format property storage.
62
     *
63
     * @var int The output cipher format.
64
     */
65
    protected $format = 0;
66
67
    /**
68
     * Encryption layer configuration constructor.
69
     *
70
     * @param string $cipher The cipher object name.
71
     * @param string $key The secret key.
72
     * @param string $iv The initialization vector.
73
     * @param string $mode The block mode.
74
     * @param int $padding The padding standard.
75
     * @param int $format The output cipher format.
76
     *
77
     * @throws \Exception Validation errors.
78
     */
79 26
    public function __construct($cipher = '', $key = '', $iv = '', $mode = '', $padding = 1, $format = 3)
80
    {
81 26
        $this->__set('cipher', $cipher);
82 26
        $this->__set('key', $key);
83 26
        $this->__set('iv', $iv);
84 26
        $this->__set('mode', $mode);
85 26
        $this->__set('padding', $padding);
86 26
        $this->__set('format', $format);
87
    }
88
89
    /**
90
     * Encryption layer destructor
91
     */
92 26
    public function __destruct()
93
    {
94 26
    }
95
96
    /**
97
     * The encryption layer string representation.
98
     *
99
     * @return string
100
     */
101 2
    public function __toString()
102
    {
103 2
        return 'cipher : ' . $this->cipher .
104 2
            ' | key : ' . $this->key .
105 2
            ' | iv : ' . $this->iv .
106 2
            ' | mode : ' . $this->mode .
107 2
            ' | padding : ' . $this->padding .
108 2
            ' | format : ' . $this->format;
109
    }
110
}
111