IPv4Address   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
namespace ValueObjects\Web;
4
5
use ValueObjects\Exception\InvalidNativeArgumentException;
6
7
class IPv4Address extends IPAddress
8
{
9
    /**
10
     * Returns a new IPv4Address
11
     *
12
     * @param string $value
13
     */
14 2
    public function __construct($value)
15
    {
16 2
        $filteredValue = filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
17
18 2
        if ($filteredValue === false) {
19 1
            throw new InvalidNativeArgumentException($value, array('string (valid ipv4 address)'));
20
        }
21
22 1
        $this->value = $filteredValue;
23 1
    }
24
}
25