Passed
Push — master ( 532106...9e740c )
by thomas
16:39
created

PingSerializer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Networking\Serializer\Message;
6
7
use BitWasp\Bitcoin\Networking\Messages\Ping;
8
use BitWasp\Buffertools\BufferInterface;
9
use BitWasp\Buffertools\Parser;
10
11
class PingSerializer
12
{
13
    /**
14 12
     * @param Ping $ping
15
     * @return BufferInterface
16 12
     */
17 12
    public function serialize(Ping $ping): BufferInterface
18 12
    {
19
        return $ping->getNonce();
20
    }
21
22
    /**
23
     * @param Parser $parser
24
     * @return Ping
25 9
     */
26
    public function fromParser(Parser $parser): Ping
27 9
    {
28 9
        return new Ping($parser->readBytes(8));
29 6
    }
30
31
    /**
32
     * @param BufferInterface $data
33
     * @return Ping
34
     */
35
    public function parse(BufferInterface $data): Ping
36 6
    {
37
        return $this->fromParser(new Parser($data));
38 6
    }
39
}
40