Completed
Pull Request — master (#85)
by thomas
02:23
created

NetworkAddressTimestamp   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTimestamp() 0 4 1
A getBuffer() 0 4 1
A __construct() 0 5 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 12
    public function __construct($time, $services, IpInterface $ip, $port)
23
    {
24 12
        $this->time = $time;
25 12
        parent::__construct($services, $ip, $port);
26 12
    }
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 3
    public function withoutTimestamp()
40
    {
41 3
        return new NetworkAddress(
42 3
            $this->getServices(),
43 3
            $this->getIp(),
44 3
            $this->getPort()
45 1
        );
46
    }
47
48
    /**
49
     * @return BufferInterface
50
     */
51 3
    public function getBuffer()
52
    {
53 3
        return (new NetworkAddressTimestampSerializer())->serialize($this);
54
    }
55
}
56