1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace VDB\Spider\Uri; |
4
|
|
|
|
5
|
|
|
use VDB\Uri\UriInterface; |
6
|
|
|
use VDB\Uri\Uri; |
7
|
|
|
|
8
|
|
|
abstract class UriDecorator implements UriInterface |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var UriInterface |
12
|
|
|
*/ |
13
|
|
|
protected $decorated; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @param string|UriInterface $decorated |
17
|
|
|
*/ |
18
|
|
|
public function __construct($decorated) |
19
|
|
|
{ |
20
|
|
|
if (!$decorated instanceof UriInterface) { |
21
|
|
|
$decorated = new Uri($decorated); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$this->decorated = $decorated; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
// @codeCoverageIgnoreStart |
28
|
|
|
// We ignore coverage for all proxy methods below: |
29
|
|
|
// the constructor is tested and if that is successful there is no point |
30
|
|
|
// to testing the behaviour of the decorated class |
31
|
|
|
|
32
|
|
|
public function toString() |
33
|
|
|
{ |
34
|
|
|
return $this->decorated->toString(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param UriInterface $that |
39
|
|
|
* @param boolean $normalized whether to compare normalized versions of the URIs |
40
|
|
|
* @return boolean |
41
|
|
|
*/ |
42
|
|
|
public function equals(UriInterface $that, $normalized = false) |
43
|
|
|
{ |
44
|
|
|
return $this->decorated->equals($that, $normalized); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return UriInterface |
49
|
|
|
*/ |
50
|
|
|
public function normalize() |
51
|
|
|
{ |
52
|
|
|
return $this->decorated->normalize(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Alias of Uri::toString() |
57
|
|
|
* |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function __toString() |
61
|
|
|
{ |
62
|
|
|
return $this->decorated->__toString(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string|null |
67
|
|
|
*/ |
68
|
|
|
public function getHost() |
69
|
|
|
{ |
70
|
|
|
return $this->decorated->getHost(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string|null |
75
|
|
|
*/ |
76
|
|
|
public function getPassword() |
77
|
|
|
{ |
78
|
|
|
return $this->decorated->getPassword(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string|null |
83
|
|
|
*/ |
84
|
|
|
public function getPath() |
85
|
|
|
{ |
86
|
|
|
return $this->decorated->getPath(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return int|null |
91
|
|
|
*/ |
92
|
|
|
public function getPort() |
93
|
|
|
{ |
94
|
|
|
return $this->decorated->getPort(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return string|null |
99
|
|
|
*/ |
100
|
|
|
public function getQuery() |
101
|
|
|
{ |
102
|
|
|
return $this->decorated->getQuery(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return string|null |
107
|
|
|
*/ |
108
|
|
|
public function getScheme() |
109
|
|
|
{ |
110
|
|
|
return $this->decorated->getScheme(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string|null |
115
|
|
|
*/ |
116
|
|
|
public function getUsername() |
117
|
|
|
{ |
118
|
|
|
return $this->decorated->getUsername(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return string|null |
123
|
|
|
*/ |
124
|
|
|
public function getFragment() |
125
|
|
|
{ |
126
|
|
|
return $this->decorated->getFragment(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
// @codeCoverageIgnoreEnd |
130
|
|
|
} |
131
|
|
|
|