Pong::getNetworkCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Networking\Messages;
6
7
use BitWasp\Bitcoin\Networking\Message;
8
use BitWasp\Bitcoin\Networking\NetworkSerializable;
9
use BitWasp\Bitcoin\Networking\Serializer\Message\PongSerializer;
10
use BitWasp\Buffertools\BufferInterface;
11
12
class Pong extends NetworkSerializable
13
{
14
    /**
15
     * @var BufferInterface
16
     */
17
    private $nonce;
18
19 9
    /**
20
     * @param BufferInterface $nonce
21 9
     */
22 9
    public function __construct(BufferInterface $nonce)
23
    {
24
        if ($nonce->getSize() !== 8) {
25
            throw new \RuntimeException("Invalid nonce size");
26
        }
27 9
        $this->nonce = $nonce;
28
    }
29 9
30
    /**
31
     * @return string
32
     * @see https://en.bitcoin.it/wiki/Protocol_documentation#pong
33
     */
34
    public function getNetworkCommand(): string
35 9
    {
36
        return Message::PONG;
37 9
    }
38
39
    /**
40
     * @return BufferInterface
41
     */
42
    public function getNonce(): BufferInterface
43 9
    {
44
        return $this->nonce;
45 9
    }
46
47
    /**
48
     * @return BufferInterface
49
     */
50
    public function getBuffer(): BufferInterface
51
    {
52
        return (new PongSerializer())->serialize($this);
53
    }
54
}
55