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

ExchangeInformation   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 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
    public function __construct($prime = '', $generator = '', $privateKey = '', $publicKey = '')
60
    {
61
        if (is_string($prime)) {
1 ignored issue
show
introduced by
The condition is_string($prime) is always true.
Loading history...
62
            $this->prime = $prime;
63
        }
64
65
        if (is_string($generator)) {
1 ignored issue
show
introduced by
The condition is_string($generator) is always true.
Loading history...
66
            $this->generator = $generator;
67
        }
68
69
        if (is_string($privateKey)) {
1 ignored issue
show
introduced by
The condition is_string($privateKey) is always true.
Loading history...
70
            $this->private = $privateKey;
71
        }
72
73
        if (is_string($publicKey)) {
1 ignored issue
show
introduced by
The condition is_string($publicKey) is always true.
Loading history...
74
            $this->public = $publicKey;
75
        }
76
    }
77
78
    /**
79
     * Exchange information destructor
80
     */
81
    public function __destruct()
82
    {
83
    }
84
85
    /**
86
     * The key exchange information data string representation.
87
     *
88
     * @return string
89
     */
90
    public function __toString()
91
    {
92
        return 'prime : ' . $this->prime .
93
            ' | generator : ' . $this->generator .
94
            ' | private : ' . $this->private .
95
            ' | public : ' . $this->public;
96
    }
97
}
98