NetworkAddress   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 59
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPort() 0 3 1
A getServices() 0 3 1
A getIp() 0 3 1
A getBuffer() 0 3 1
A __construct() 0 5 1
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