NetworkAddressTimestamp   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 49
ccs 8
cts 14
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getBuffer() 0 3 1
A getTimestamp() 0 3 1
A __construct() 0 8 1
A withoutTimestamp() 0 6 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\NetworkAddressTimestampSerializer;
9
use BitWasp\Buffertools\BufferInterface;
10
11
class NetworkAddressTimestamp extends NetworkAddress
12
{
13
    /**
14
     * @var int
15
     */
16
    private $time;
17
18
    /**
19
     * @param int $time
20
     * @param int $services
21
     * @param IpInterface $ip
22 14
     * @param int $port
23
     */
24 14
    public function __construct(
25 14
        int $time,
26 14
        int $services,
27
        IpInterface $ip,
28
        int $port
29
    ) {
30
        $this->time = $time;
31 6
        parent::__construct($services, $ip, $port);
32
    }
33 6
34
    /**
35
     * @return int
36
     */
37
    public function getTimestamp(): int
38
    {
39
        return $this->time;
40
    }
41
42
    /**
43
     * @return NetworkAddress
44
     */
45
    public function withoutTimestamp(): NetworkAddress
46
    {
47
        return new NetworkAddress(
48
            $this->getServices(),
49
            $this->getIp(),
50
            $this->getPort()
51 3
        );
52
    }
53 3
54
    /**
55
     * @return BufferInterface
56
     */
57
    public function getBuffer(): BufferInterface
58
    {
59
        return (new NetworkAddressTimestampSerializer())->serialize($this);
60
    }
61
}
62