Path::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 5
nc 2
nop 1
crap 3
1
<?php
2
3
namespace ValueObjects\Web;
4
5
use ValueObjects\Exception\InvalidNativeArgumentException;
6
use ValueObjects\StringLiteral\StringLiteral;
7
8
class Path extends StringLiteral
9
{
10 15
    public function __construct($value)
11
    {
12 15
        $filteredValue = parse_url($value, PHP_URL_PATH);
13
14 15
        if (null === $filteredValue || strlen($filteredValue) != strlen($value)) {
15 1
            throw new InvalidNativeArgumentException($value, array('string (valid url path)'));
16
        }
17
18 14
        $this->value = $filteredValue;
19 14
    }
20
}
21