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

MacAddress::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 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