Url::asString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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