Completed
Pull Request — master (#71)
by
unknown
02:09
created

MacAddress   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

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