URI::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Internet;
4
5
use BestServedCold\PhalueObjects\Exception\InvalidTypeException;
6
use BestServedCold\PhalueObjects\ValueObject;
7
8
/**
9
 * Class URI
10
 *
11
 * @package   BestServedCold\PhalueObjects
12
 * @author    Adam Lewis <[email protected]>
13
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
14
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
15
 * @link      http://bestservedcold.com
16
 * @since     0.0.1-alpha
17
 * @version   0.0.2-alpha
18
 */
19
class URI extends ValueObject
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $protocol;
25
26
    /**
27
     * @var string
28
     */
29
    protected $host;
30
31
    /**
32
     * @param $value
33
     */
34 1
    public function __construct($value)
35
    {
36 1
        if (!filter_var($value, FILTER_VALIDATE_URL)) {
37 1
            throw new InvalidTypeException($value, [ 'url' ]);
38
        }
39
40 1
        parent::__construct($value);
41 1
    }
42
}
43