CryptoKeypairAbstract::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Class CryptoKeypairAbstract
4
 *
5
 * @filesource   CryptoKeypairAbstract.php
6
 * @created      24.01.2018
7
 * @package      chillerlan\Cryptobox
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2018 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Cryptobox;
14
15
use function property_exists;
16
17
/**
18
 * @link https://paragonie.com/book/pecl-libsodium/read/00-intro.md
19
 * @link https://paragonie.com/book/pecl-libsodium/read/01-quick-start.md
20
 */
21
abstract class CryptoKeypairAbstract implements CryptoKeypairInterface{
22
23
	/**
24
	 * @var string
25
	 */
26
	protected $keypair;
27
28
	/**
29
	 * @var string
30
	 */
31
	protected $secret;
32
33
	/**
34
	 * @var string
35
	 */
36
	protected $public;
37
38
	/**
39
	 * CryptoKeypairAbstract constructor.
40
	 *
41
	 * @param string|null $secret_bin
42
	 * @param string|null $public_bin
43
	 */
44
	public function __construct(string $secret_bin = null, string $public_bin = null){
45
		$this->secret = $secret_bin;
46
		$this->public = $public_bin;
47
	}
48
49
	/**
50
	 * @param string $property
51
	 *
52
	 * @return mixed|null
53
	 */
54
	public function __get(string $property){
55
		return property_exists($this, $property) ? $this->{$property} : null;
56
	}
57
58
}
59