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

PongSerializer::__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\Pong;
8
use BitWasp\Buffertools\BufferInterface;
9
use BitWasp\Buffertools\Parser;
10
11
class PongSerializer
12
{
13
    /**
14 9
     * @param Pong $pong
15
     * @return BufferInterface
16 9
     */
17 9
    public function serialize(Pong $pong): BufferInterface
18 9
    {
19
        return $pong->getNonce();
20
    }
21
22
    /**
23
     * @param Parser $parser
24
     * @return Pong
25 9
     */
26
    public function fromParser(Parser $parser): Pong
27 9
    {
28 9
        return new Pong($parser->readBytes(8));
29 6
    }
30
31
    /**
32
     * @param BufferInterface $data
33
     * @return Pong
34
     */
35
    public function parse(BufferInterface $data): Pong
36 3
    {
37
        return $this->fromParser(new Parser($data));
38 3
    }
39
}
40