Completed
Pull Request — master (#71)
by
unknown
09:44 queued 07:23
created

MacAddress::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
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
    public function __construct($value)
16
    {
17
        if (0 === \preg_match('/^(?:[0-9a-f]{2}([-:]))(?:[0-9a-f]{2}\1){4}[0-9a-f]{2}$/i', $value)) {
18
            throw new InvalidNativeArgumentException($value, array('string (valid Mac address)'));
19
        }
20
21
        $this->value = $value;
22
    }
23
}
24