Completed
Push — master ( 5c76e6...b6ee5b )
by Oscar
03:07
created

Uri::userInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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