Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | class Ping extends NetworkSerializable |
||
14 | { |
||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | private $nonce; |
||
19 | |||
20 | /** |
||
21 | 9 | * Ping constructor. |
|
22 | * @param int $nonce |
||
23 | 9 | */ |
|
24 | 9 | public function __construct(int $nonce) |
|
25 | { |
||
26 | $this->nonce = $nonce; |
||
27 | } |
||
28 | |||
29 | 9 | /** |
|
30 | * @param Random $random |
||
31 | 9 | * @return Ping |
|
32 | * @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure |
||
33 | */ |
||
34 | public static function generate(Random $random): Ping |
||
35 | { |
||
36 | $nonce = (int) $random->bytes(8)->getInt(); |
||
37 | 18 | return new Ping($nonce); |
|
38 | } |
||
39 | 18 | ||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | public function getNetworkCommand(): string |
||
44 | { |
||
45 | 9 | return Message::PING; |
|
46 | } |
||
47 | 9 | ||
48 | /** |
||
49 | * @return int |
||
50 | */ |
||
51 | public function getNonce() |
||
52 | { |
||
53 | return $this->nonce; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return BufferInterface |
||
58 | */ |
||
59 | public function getBuffer(): BufferInterface |
||
62 | } |
||
63 | } |
||
64 |