Uri   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 123
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 9
dl 0
loc 123
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A scheme() 0 4 1
A authority() 0 4 1
A userInfo() 0 4 1
A host() 0 4 1
A port() 0 4 1
A path() 0 4 1
A query() 0 4 1
A fragment() 0 4 1
1
<?php
2
3
namespace Psr7Unitesting;
4
5
use Psr\Http\Message\UriInterface;
6
7
/**
8
 * Class to execute assertions with a UriInterface instance.
9
 */
10
class Uri extends Utils\AbstractAssert
11
{
12
    /**
13
     * @var UriInterface
14
     */
15
    protected $uri;
16
17
    /**
18
     * Constructor.
19
     *
20
     * @param UriInterface        $uri
21
     * @param AbstractAssert|null $previous
22
     */
23
    public function __construct(UriInterface $uri, Utils\AbstractAssert $previous = null)
24
    {
25
        $this->uri = $uri;
26
        $this->previous($previous);
27
    }
28
29
    /**
30
     * Asserts the url scheme.
31
     *
32
     * @param string $scheme
33
     * @param string $message
34
     *
35
     * @return self
36
     */
37
    public function scheme($scheme, $message = '')
38
    {
39
        return $this->assert($this->uri, new Uri\Scheme($scheme), $message);
40
    }
41
42
    /**
43
     * Asserts the url authority.
44
     *
45
     * @param string $authority
46
     * @param string $message
47
     *
48
     * @return self
49
     */
50
    public function authority($authority, $message = '')
51
    {
52
        return $this->assert($this->uri, new Uri\Authority($authority), $message);
53
    }
54
55
    /**
56
     * Asserts the url user info.
57
     *
58
     * @param string $userInfo
59
     * @param string $message
60
     *
61
     * @return self
62
     */
63
    public function userInfo($userInfo, $message = '')
64
    {
65
        return $this->assert($this->uri, new Uri\UserInfo($userInfo), $message);
66
    }
67
68
    /**
69
     * Asserts the url host.
70
     *
71
     * @param string $host
72
     * @param string $message
73
     *
74
     * @return self
75
     */
76
    public function host($host, $message = '')
77
    {
78
        return $this->assert($this->uri, new Uri\Host($host), $message);
79
    }
80
81
    /**
82
     * Asserts the url port.
83
     *
84
     * @param int    $port
85
     * @param string $message
86
     *
87
     * @return self
88
     */
89
    public function port($port, $message = '')
90
    {
91
        return $this->assert($this->uri, new Uri\Port($port), $message);
92
    }
93
94
    /**
95
     * Asserts the url path.
96
     *
97
     * @param int    $path
98
     * @param string $message
99
     *
100
     * @return self
101
     */
102
    public function path($path, $message = '')
103
    {
104
        return $this->assert($this->uri, new Uri\Path($path), $message);
105
    }
106
107
    /**
108
     * Asserts the url query.
109
     *
110
     * @param string $query
111
     * @param string $message
112
     *
113
     * @return self
114
     */
115
    public function query($query, $message = '')
116
    {
117
        return $this->assert($this->uri, new Uri\Query($query), $message);
118
    }
119
120
    /**
121
     * Asserts the url fragment.
122
     *
123
     * @param string $fragment
124
     * @param string $message
125
     *
126
     * @return self
127
     */
128
    public function fragment($fragment, $message = '')
129
    {
130
        return $this->assert($this->uri, new Uri\Fragment($fragment), $message);
131
    }
132
}
133