Url   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A asString() 0 4 1
A ensureUrl() 0 5 1
1
<?php
2
namespace DjThossi\SmokeTestingPhp\ValueObject;
3
4
use DjThossi\Ensure\EnsureIsStringTrait;
5
use DjThossi\Ensure\EnsureIsUrlTrait;
6
7
class Url
8
{
9
    use EnsureIsStringTrait;
10
    use EnsureIsUrlTrait;
11
12
    const URL_IS_NOT_A_STRING = 1;
13
    const URL_IS_NOT_A_URL = 2;
14
    /**
15
     * @var string
16
     */
17
    private $url;
18
19
    /**
20
     * @param string $url
21
     */
22
    public function __construct($url)
23
    {
24
        $this->ensureUrl($url);
25
26
        $this->url = $url;
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function asString()
33
    {
34
        return $this->url;
35
    }
36
37
    /**
38
     * @param $url
39
     */
40
    private function ensureUrl($url)
41
    {
42
        $this->ensureIsString('Url', $url, self::URL_IS_NOT_A_STRING);
43
        $this->ensureIsUrl('Url', $url, self::URL_IS_NOT_A_URL);
44
    }
45
}
46