NetworkAddress::getBuffer()   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
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BitWasp\Bitcoin\Networking\Structure;
6
7
use BitWasp\Bitcoin\Networking\Ip\IpInterface;
8
use BitWasp\Bitcoin\Networking\Serializer\Structure\NetworkAddressSerializer;
9
use BitWasp\Bitcoin\Serializable;
10
use BitWasp\Buffertools\BufferInterface;
11
12
class NetworkAddress extends Serializable implements NetworkAddressInterface
13
{
14
    /**
15
     * @var int
16
     */
17
    private $services;
18
19
    /**
20
     * @var IpInterface
21
     */
22
    private $ip;
23
24
    /**
25
     * @var int
26
     */
27
    private $port;
28
29
    /**
30
     * @param int $services
31
     * @param IpInterface $ip
32 83
     * @param int $port
33
     */
34 83
    public function __construct(int $services, IpInterface $ip, int $port)
35 83
    {
36 83
        $this->services = $services;
37 83
        $this->ip = $ip;
38
        $this->port = $port;
39
    }
40
41
    /**
42 42
     * @return int
43
     */
44 42
    public function getServices(): int
45
    {
46
        return $this->services;
47
    }
48
49
    /**
50 42
     * @return IpInterface
51
     */
52 42
    public function getIp(): IpInterface
53
    {
54
        return $this->ip;
55
    }
56
57
    /**
58 42
     * @return int
59
     */
60 42
    public function getPort(): int
61
    {
62
        return $this->port;
63
    }
64
65
    /**
66 27
     * @return BufferInterface
67
     */
68 27
    public function getBuffer(): BufferInterface
69
    {
70
        return (new NetworkAddressSerializer())->serialize($this);
71
    }
72
}
73