Completed
Push — master ( cf79ad...e9ba59 )
by Tony Karavasilev (Тони
18:41
created

ExchangeInformation::__construct()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 9.6111
cc 5
nc 16
nop 4
crap 5
1
<?php
2
3
/**
4
 * The key exchange information data object.
5
 */
6
7
namespace CryptoManana\DataStructures;
8
9
use \CryptoManana\Core\Abstractions\DataStructures\AbstractBasicStructure as BasicDataStructure;
10
11
/**
12
 * Class ExchangeInformation - The key exchange information data object.
13
 *
14
 * @package CryptoManana\DataStructures
15
 *
16
 * @property string $prime The hexadecimal representation of a prime number, also knows as `p`.
17
 * @property string $generator The hexadecimal generator number, a primitive root modulo of `p`, also known as `g`.
18
 * @property string $private The private key.
19
 * @property string $public The public key.
20
 */
21
class ExchangeInformation extends BasicDataStructure
22
{
23
    /**
24
     * The prime number property storage.
25
     *
26
     * @var string The chosen prime number, also knows as `p`
27
     */
28
    protected $prime = '';
29
30
    /**
31
     * The generator number property storage.
32
     *
33
     * @var string The chosen generator number, also knows as `g`
34
     */
35
    protected $generator = '';
36
37
    /**
38
     * The private key property storage.
39
     *
40
     * @var string The private key.
41
     */
42
    protected $private = '';
43
44
    /**
45
     * The public key property storage.
46
     *
47
     * @var string The public key.
48
     */
49
    protected $public = '';
50
51
    /**
52
     * Exchange information constructor.
53
     *
54
     * @param string $prime The hexadecimal representation of a prime number, also knows as `p`.
55
     * @param string $generator The hexadecimal generator number, a primitive root modulo of `p`, also known as `g`.
56
     * @param string $privateKey The private key.
57
     * @param string $publicKey The public key.
58
     */
59 24
    public function __construct($prime = '', $generator = '', $privateKey = '', $publicKey = '')
60
    {
61 24
        if (is_string($prime)) {
1 ignored issue
show
introduced by
The condition is_string($prime) is always true.
Loading history...
62 24
            $this->prime = $prime;
63
        }
64
65 24
        if (is_string($generator)) {
1 ignored issue
show
introduced by
The condition is_string($generator) is always true.
Loading history...
66 24
            $this->generator = $generator;
67
        }
68
69 24
        if (is_string($privateKey)) {
1 ignored issue
show
introduced by
The condition is_string($privateKey) is always true.
Loading history...
70 24
            $this->private = $privateKey;
71
        }
72
73 24
        if (is_string($publicKey)) {
1 ignored issue
show
introduced by
The condition is_string($publicKey) is always true.
Loading history...
74 24
            $this->public = $publicKey;
75
        }
76 24
    }
77
78
    /**
79
     * Exchange information destructor
80
     */
81 24
    public function __destruct()
82
    {
83 24
    }
84
85
    /**
86
     * The key exchange information data string representation.
87
     *
88
     * @return string
89
     */
90 4
    public function __toString()
91
    {
92 4
        return 'prime : ' . $this->prime .
93 4
            ' | generator : ' . $this->generator .
94 4
            ' | private : ' . $this->private .
95 4
            ' | public : ' . $this->public;
96
    }
97
}
98