Passed
Push — staging ( c0f39d...5ba460 )
by Tony Karavasilev (Тони
03:57
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
 * @param string $cipher = The cipher object name.
15
 * @param string $key The secret key.
16
 * @param string $iv The initialization vector.
17
 * @param string $mode The block mode.
18
 * @param int $padding The padding standard.
19
 * @param int $format The output cipher format.
20
 *
21
 * @package CryptoManana\DataStructures
22
 *
23
 */
24
class EncryptionLayer extends BasicDataStructure
25
{
26
    /**
27
     * The symmetric encryption cipher object name property storage.
28
     *
29
     * @var string The cipher object name.
30
     */
31
    protected $cipher = '';
32
33
    /**
34
     * The symmetric encryption secret key property storage.
35
     *
36
     * @var string The secret key.
37
     */
38
    protected $key = '';
39
40
    /**
41
     * The symmetric encryption initialization vector property storage.
42
     *
43
     * @var string The initialization vector.
44
     */
45
    protected $iv = '';
46
47
    /**
48
     * The symmetric encryption block mode property storage.
49
     *
50
     * @var string The block mode.
51
     */
52
    protected $mode = '';
53
54
    /**
55
     * The symmetric encryption padding standard property storage.
56
     *
57
     * @var int The padding standard.
58
     */
59
    protected $padding = 0;
60
61
    /**
62
     * The symmetric encryption output cipher format property storage.
63
     *
64
     * @var int The output cipher format.
65
     */
66
    protected $format = 0;
67
68
    /**
69
     * Encryption layer configuration constructor.
70
     *
71
     * @param string $cipher = The cipher object name.
72
     * @param string $key The secret key.
73
     * @param string $iv The initialization vector.
74
     * @param string $mode The block mode.
75
     * @param int $padding The padding standard.
76
     * @param int $format The output cipher format.
77
     *
78
     * @throws \Exception Validation errors.
79
     */
80 26
    public function __construct($cipher = '', $key = '', $iv = '', $mode = '', $padding = 1, $format = 3)
81
    {
82 26
        $this->__set('cipher', $cipher);
83 26
        $this->__set('key', $key);
84 26
        $this->__set('iv', $iv);
85 26
        $this->__set('mode', $mode);
86 26
        $this->__set('padding', $padding);
87 26
        $this->__set('format', $format);
88
    }
89
90
    /**
91
     * Encryption layer destructor
92
     */
93 26
    public function __destruct()
94
    {
95 26
    }
96
97
    /**
98
     * The encryption layer string representation.
99
     *
100
     * @return string
101
     */
102 2
    public function __toString()
103
    {
104 2
        return 'cipher : ' . $this->cipher .
105 2
            ' | key : ' . $this->key .
106 2
            ' | iv : ' . $this->iv .
107 2
            ' | mode : ' . $this->mode .
108 2
            ' | padding : ' . $this->padding .
109 2
            ' | format : ' . $this->format;
110
    }
111
}
112