Completed
Push — master ( 4c10a8...999ca2 )
by thomas
8s
created

NetworkAddressTimestamp   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 57.14%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 47
ccs 8
cts 14
cp 0.5714
rs 10

4 Methods

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