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

PongSerializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 3 1
A parse() 0 3 1
A fromParser() 0 3 1
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