Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class Ipv4 implements IpInterface |
||
11 | { |
||
12 | const MAGIC = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff"; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | private $ip; |
||
18 | |||
19 | /** |
||
20 | * Ipv4 constructor. |
||
21 | 86 | * @param string $ip |
|
22 | */ |
||
23 | 86 | public function __construct(string $ip) |
|
24 | 3 | { |
|
25 | if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
||
26 | throw new \InvalidArgumentException('IPv4: a valid IPv4 address is required'); |
||
27 | 83 | } |
|
28 | 83 | ||
29 | $this->ip = $ip; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | 30 | * @return string |
|
34 | */ |
||
35 | 30 | public function getHost(): string |
|
36 | { |
||
37 | return $this->ip; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | 36 | * @return BufferInterface |
|
42 | */ |
||
43 | 36 | public function getBuffer(): BufferInterface |
|
47 | ); |
||
48 | } |
||
49 | } |
||
50 |