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

KeyPair   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 1
b 0
f 0
dl 0
loc 48
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 1
A __construct() 0 8 3
A __destruct() 0 2 1
1
<?php
2
3
/**
4
 * The asymmetric key-pair object.
5
 */
6
7
namespace CryptoManana\DataStructures;
8
9
use \CryptoManana\Core\Abstractions\DataStructures\AbstractBasicStructure as BasicDataStructure;
10
11
/**
12
 * Class KeyPair - The key-pair object.
13
 *
14
 * @package CryptoManana\DataStructures
15
 *
16
 * @property string $private The private key.
17
 * @property string $public The public key.
18
 */
19
class KeyPair extends BasicDataStructure
20
{
21
    /**
22
     * The private key property storage.
23
     *
24
     * @var string The private key.
25
     */
26
    protected $private = '';
27
28
    /**
29
     * The public key property storage.
30
     *
31
     * @var string The public key.
32
     */
33
    protected $public = '';
34
35
    /**
36
     * Key-pair constructor.
37
     *
38
     * @param string $privateKey The private key string.
39
     * @param string $publicKey The public key string.
40
     */
41 562
    public function __construct($privateKey = '', $publicKey = '')
42
    {
43 562
        if (is_string($privateKey)) {
1 ignored issue
show
introduced by
The condition is_string($privateKey) is always true.
Loading history...
44 562
            $this->private = $privateKey;
45
        }
46
47 562
        if (is_string($publicKey)) {
1 ignored issue
show
introduced by
The condition is_string($publicKey) is always true.
Loading history...
48 562
            $this->public = $publicKey;
49
        }
50 562
    }
51
52
    /**
53
     * Key-pair destructor
54
     */
55 562
    public function __destruct()
56
    {
57 562
    }
58
59
    /**
60
     * The key-pair string representation.
61
     *
62
     * @return string
63
     */
64
    public function __toString()
65
    {
66
        return 'private : ' . $this->private . ' | public : ' . $this->public;
67
    }
68
}
69