@@ -19,34 +19,34 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class RequestHelper_Boundaries_Boundary |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | protected $content; |
26 | 26 | |
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var array |
|
29 | + */ |
|
30 | 30 | protected $dispositionParams = array(); |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $contentType = ''; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string |
|
39 | + */ |
|
40 | 40 | protected $contentEncoding = ''; |
41 | 41 | |
42 | - /** |
|
43 | - * @var RequestHelper_Boundaries |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var RequestHelper_Boundaries |
|
44 | + */ |
|
45 | 45 | protected $boundaries; |
46 | 46 | |
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | 50 | protected $transferEncoding = ''; |
51 | 51 | |
52 | 52 | public function __construct(RequestHelper_Boundaries $boundaries, string $content) |
@@ -60,46 +60,46 @@ discard block |
||
60 | 60 | return strlen($this->content); |
61 | 61 | } |
62 | 62 | |
63 | - /** |
|
64 | - * Sets the name of the request parameter. |
|
65 | - * |
|
66 | - * @param string $name |
|
67 | - * @return RequestHelper_Boundaries_Boundary |
|
68 | - */ |
|
63 | + /** |
|
64 | + * Sets the name of the request parameter. |
|
65 | + * |
|
66 | + * @param string $name |
|
67 | + * @return RequestHelper_Boundaries_Boundary |
|
68 | + */ |
|
69 | 69 | public function setName(string $name) : RequestHelper_Boundaries_Boundary |
70 | 70 | { |
71 | 71 | return $this->setDispositionParam('name', $name); |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Sets the filename to use for the content, if applicable. |
|
76 | - * |
|
77 | - * @param string $fileName |
|
78 | - * @return RequestHelper_Boundaries_Boundary |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Sets the filename to use for the content, if applicable. |
|
76 | + * |
|
77 | + * @param string $fileName |
|
78 | + * @return RequestHelper_Boundaries_Boundary |
|
79 | + */ |
|
80 | 80 | public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary |
81 | 81 | { |
82 | 82 | return $this->setDispositionParam('filename', $fileName); |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Sets the content type to use for the content. |
|
87 | - * |
|
88 | - * @param string $contentType |
|
89 | - * @return RequestHelper_Boundaries_Boundary |
|
90 | - */ |
|
85 | + /** |
|
86 | + * Sets the content type to use for the content. |
|
87 | + * |
|
88 | + * @param string $contentType |
|
89 | + * @return RequestHelper_Boundaries_Boundary |
|
90 | + */ |
|
91 | 91 | public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary |
92 | 92 | { |
93 | 93 | $this->contentType = $contentType; |
94 | 94 | return $this; |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * Sets the encoding to specify for the content. |
|
99 | - * |
|
100 | - * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
101 | - * @return RequestHelper_Boundaries_Boundary |
|
102 | - */ |
|
97 | + /** |
|
98 | + * Sets the encoding to specify for the content. |
|
99 | + * |
|
100 | + * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
101 | + * @return RequestHelper_Boundaries_Boundary |
|
102 | + */ |
|
103 | 103 | public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary |
104 | 104 | { |
105 | 105 | $this->contentEncoding = $encoding; |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | return $this; |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Renders the mime boundary text. |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
122 | + /** |
|
123 | + * Renders the mime boundary text. |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | 127 | public function render() |
128 | 128 | { |
129 | 129 | $eol = $this->boundaries->getEOL(); |
@@ -39,66 +39,66 @@ discard block |
||
39 | 39 | |
40 | 40 | const ERROR_CANNOT_OPEN_LOGFILE = 17904; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $eol = "\r\n"; |
46 | 46 | |
47 | - /** |
|
48 | - * @var string |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var string |
|
49 | + */ |
|
50 | 50 | protected $mimeBoundary; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | protected $data = ''; |
56 | 56 | |
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | 60 | protected $destination; |
61 | 61 | |
62 | - /** |
|
63 | - * @var array |
|
64 | - */ |
|
62 | + /** |
|
63 | + * @var array |
|
64 | + */ |
|
65 | 65 | protected $headers = array(); |
66 | 66 | |
67 | - /** |
|
68 | - * Whether to verify SSL certificates. |
|
69 | - * @var bool |
|
70 | - */ |
|
67 | + /** |
|
68 | + * Whether to verify SSL certificates. |
|
69 | + * @var bool |
|
70 | + */ |
|
71 | 71 | protected $verifySSL = true; |
72 | 72 | |
73 | - /** |
|
74 | - * @var RequestHelper_Boundaries |
|
75 | - */ |
|
73 | + /** |
|
74 | + * @var RequestHelper_Boundaries |
|
75 | + */ |
|
76 | 76 | protected $boundaries; |
77 | 77 | |
78 | - /** |
|
79 | - * @var RequestHelper_Response|NULL |
|
80 | - */ |
|
78 | + /** |
|
79 | + * @var RequestHelper_Response|NULL |
|
80 | + */ |
|
81 | 81 | protected $response; |
82 | 82 | |
83 | - /** |
|
84 | - * @var integer |
|
85 | - */ |
|
83 | + /** |
|
84 | + * @var integer |
|
85 | + */ |
|
86 | 86 | protected $timeout = 30; |
87 | 87 | |
88 | - /** |
|
89 | - * @var string |
|
90 | - */ |
|
88 | + /** |
|
89 | + * @var string |
|
90 | + */ |
|
91 | 91 | protected $logfile = ''; |
92 | 92 | |
93 | - /** |
|
94 | - * @var resource|NULL |
|
95 | - */ |
|
93 | + /** |
|
94 | + * @var resource|NULL |
|
95 | + */ |
|
96 | 96 | protected $logfilePointer = null; |
97 | 97 | |
98 | - /** |
|
99 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
100 | - * @param string $destinationURL |
|
101 | - */ |
|
98 | + /** |
|
99 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
100 | + * @param string $destinationURL |
|
101 | + */ |
|
102 | 102 | public function __construct(string $destinationURL) |
103 | 103 | { |
104 | 104 | $this->destination = $destinationURL; |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | return $this; |
131 | 131 | } |
132 | 132 | |
133 | - /** |
|
134 | - * Enables verbose logging of the CURL request, which |
|
135 | - * is then redirected to the target file. |
|
136 | - * |
|
137 | - * @param string $targetFile |
|
138 | - * @return RequestHelper |
|
139 | - */ |
|
133 | + /** |
|
134 | + * Enables verbose logging of the CURL request, which |
|
135 | + * is then redirected to the target file. |
|
136 | + * |
|
137 | + * @param string $targetFile |
|
138 | + * @return RequestHelper |
|
139 | + */ |
|
140 | 140 | public function enableLogging(string $targetFile) : RequestHelper |
141 | 141 | { |
142 | 142 | $this->logfile = $targetFile; |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | return $this; |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Adds a file to be sent with the request. |
|
149 | - * |
|
150 | - * @param string $varName The variable name to send the file in |
|
151 | - * @param string $fileName The name of the file as it should be received at the destination |
|
152 | - * @param string $content The raw content of the file |
|
153 | - * @param string $contentType The content type, use the constants to specify this |
|
154 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
155 | - */ |
|
147 | + /** |
|
148 | + * Adds a file to be sent with the request. |
|
149 | + * |
|
150 | + * @param string $varName The variable name to send the file in |
|
151 | + * @param string $fileName The name of the file as it should be received at the destination |
|
152 | + * @param string $content The raw content of the file |
|
153 | + * @param string $contentType The content type, use the constants to specify this |
|
154 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
155 | + */ |
|
156 | 156 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
157 | 157 | { |
158 | 158 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | return $this; |
161 | 161 | } |
162 | 162 | |
163 | - /** |
|
164 | - * Adds arbitrary content. |
|
165 | - * |
|
166 | - * @param string $varName The variable name to send the content in. |
|
167 | - * @param string $content |
|
168 | - * @param string $contentType |
|
169 | - */ |
|
163 | + /** |
|
164 | + * Adds arbitrary content. |
|
165 | + * |
|
166 | + * @param string $varName The variable name to send the content in. |
|
167 | + * @param string $content |
|
168 | + * @param string $contentType |
|
169 | + */ |
|
170 | 170 | public function addContent(string $varName, string $content, string $contentType) : RequestHelper |
171 | 171 | { |
172 | 172 | $this->boundaries->addContent($varName, $content, $contentType); |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | return $this; |
189 | 189 | } |
190 | 190 | |
191 | - /** |
|
192 | - * Sets an HTTP header to include in the request. |
|
193 | - * |
|
194 | - * @param string $name |
|
195 | - * @param string $value |
|
196 | - * @return RequestHelper |
|
197 | - */ |
|
191 | + /** |
|
192 | + * Sets an HTTP header to include in the request. |
|
193 | + * |
|
194 | + * @param string $name |
|
195 | + * @param string $value |
|
196 | + * @return RequestHelper |
|
197 | + */ |
|
198 | 198 | public function setHeader(string $name, string $value) : RequestHelper |
199 | 199 | { |
200 | 200 | $this->headers[$name] = $value; |
@@ -202,36 +202,36 @@ discard block |
||
202 | 202 | return $this; |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Disables SSL certificate checking. |
|
207 | - * |
|
208 | - * @return RequestHelper |
|
209 | - */ |
|
205 | + /** |
|
206 | + * Disables SSL certificate checking. |
|
207 | + * |
|
208 | + * @return RequestHelper |
|
209 | + */ |
|
210 | 210 | public function disableSSLChecks() : RequestHelper |
211 | 211 | { |
212 | 212 | $this->verifySSL = false; |
213 | 213 | return $this; |
214 | 214 | } |
215 | 215 | |
216 | - /** |
|
217 | - * @var integer |
|
218 | - */ |
|
216 | + /** |
|
217 | + * @var integer |
|
218 | + */ |
|
219 | 219 | protected $contentLength = 0; |
220 | 220 | |
221 | - /** |
|
222 | - * Sends the POST request to the destination, and returns |
|
223 | - * the response text. |
|
224 | - * |
|
225 | - * The response object is stored internally, so after calling |
|
226 | - * this method it may be retrieved at any moment using the |
|
227 | - * {@link getResponse()} method. |
|
228 | - * |
|
229 | - * @return string |
|
230 | - * @see RequestHelper::getResponse() |
|
231 | - * @throws RequestHelper_Exception |
|
232 | - * |
|
233 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
234 | - */ |
|
221 | + /** |
|
222 | + * Sends the POST request to the destination, and returns |
|
223 | + * the response text. |
|
224 | + * |
|
225 | + * The response object is stored internally, so after calling |
|
226 | + * this method it may be retrieved at any moment using the |
|
227 | + * {@link getResponse()} method. |
|
228 | + * |
|
229 | + * @return string |
|
230 | + * @see RequestHelper::getResponse() |
|
231 | + * @throws RequestHelper_Exception |
|
232 | + * |
|
233 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
234 | + */ |
|
235 | 235 | public function send() : string |
236 | 236 | { |
237 | 237 | $info = parseURL($this->destination); |
@@ -274,14 +274,14 @@ discard block |
||
274 | 274 | return $this->data; |
275 | 275 | } |
276 | 276 | |
277 | - /** |
|
278 | - * Creates a new CURL resource configured according to the |
|
279 | - * request's settings. |
|
280 | - * |
|
281 | - * @param URLInfo $url |
|
282 | - * @throws RequestHelper_Exception |
|
283 | - * @return resource |
|
284 | - */ |
|
277 | + /** |
|
278 | + * Creates a new CURL resource configured according to the |
|
279 | + * request's settings. |
|
280 | + * |
|
281 | + * @param URLInfo $url |
|
282 | + * @throws RequestHelper_Exception |
|
283 | + * @return resource |
|
284 | + */ |
|
285 | 285 | protected function createCURL(URLInfo $url) |
286 | 286 | { |
287 | 287 | $ch = curl_init(); |
@@ -329,10 +329,10 @@ discard block |
||
329 | 329 | return $ch; |
330 | 330 | } |
331 | 331 | |
332 | - /** |
|
333 | - * @param resource $ch |
|
334 | - * @return bool Whether logging is enabled. |
|
335 | - */ |
|
332 | + /** |
|
333 | + * @param resource $ch |
|
334 | + * @return bool Whether logging is enabled. |
|
335 | + */ |
|
336 | 336 | protected function configureLogging($ch) : bool |
337 | 337 | { |
338 | 338 | if(empty($this->logfile)) |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | return true; |
360 | 360 | } |
361 | 361 | |
362 | - /** |
|
363 | - * Compiles the associative headers array into |
|
364 | - * the format understood by CURL, namely an indexed |
|
365 | - * array with one header string per entry. |
|
366 | - * |
|
367 | - * @return array |
|
368 | - */ |
|
362 | + /** |
|
363 | + * Compiles the associative headers array into |
|
364 | + * the format understood by CURL, namely an indexed |
|
365 | + * array with one header string per entry. |
|
366 | + * |
|
367 | + * @return array |
|
368 | + */ |
|
369 | 369 | protected function renderHeaders() : array |
370 | 370 | { |
371 | 371 | $result = array(); |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | return $result; |
380 | 380 | } |
381 | 381 | |
382 | - /** |
|
383 | - * Retrieves the raw response header, in the form of an indexed |
|
384 | - * array containing all response header lines. |
|
385 | - * |
|
386 | - * @return array |
|
387 | - */ |
|
382 | + /** |
|
383 | + * Retrieves the raw response header, in the form of an indexed |
|
384 | + * array containing all response header lines. |
|
385 | + * |
|
386 | + * @return array |
|
387 | + */ |
|
388 | 388 | public function getResponseHeader() : array |
389 | 389 | { |
390 | 390 | $response = $this->getResponse(); |
@@ -27,73 +27,73 @@ discard block |
||
27 | 27 | */ |
28 | 28 | class OperationResult |
29 | 29 | { |
30 | - /** |
|
31 | - * @var string |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var string |
|
32 | + */ |
|
33 | 33 | protected $message = ''; |
34 | 34 | |
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | 38 | protected $valid = true; |
39 | 39 | |
40 | - /** |
|
41 | - * @var object |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var object |
|
42 | + */ |
|
43 | 43 | protected $subject; |
44 | 44 | |
45 | - /** |
|
46 | - * @var integer |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var integer |
|
47 | + */ |
|
48 | 48 | protected $code = 0; |
49 | 49 | |
50 | - /** |
|
51 | - * The subject being validated. |
|
52 | - * |
|
53 | - * @param object $subject |
|
54 | - */ |
|
50 | + /** |
|
51 | + * The subject being validated. |
|
52 | + * |
|
53 | + * @param object $subject |
|
54 | + */ |
|
55 | 55 | public function __construct(object $subject) |
56 | 56 | { |
57 | 57 | $this->subject = $subject; |
58 | 58 | } |
59 | 59 | |
60 | - /** |
|
61 | - * Whether the validation was successful. |
|
62 | - * |
|
63 | - * @return bool |
|
64 | - */ |
|
60 | + /** |
|
61 | + * Whether the validation was successful. |
|
62 | + * |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | 65 | public function isValid() : bool |
66 | 66 | { |
67 | 67 | return $this->valid; |
68 | 68 | } |
69 | 69 | |
70 | - /** |
|
71 | - * Retrieves the subject that was validated. |
|
72 | - * |
|
73 | - * @return object |
|
74 | - */ |
|
70 | + /** |
|
71 | + * Retrieves the subject that was validated. |
|
72 | + * |
|
73 | + * @return object |
|
74 | + */ |
|
75 | 75 | public function getSubject() : object |
76 | 76 | { |
77 | 77 | return $this->subject; |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Makes the result a succes, with the specified message. |
|
82 | - * |
|
83 | - * @param string $message Should not contain a date, just the system specific info. |
|
84 | - * @return OperationResult |
|
85 | - */ |
|
80 | + /** |
|
81 | + * Makes the result a succes, with the specified message. |
|
82 | + * |
|
83 | + * @param string $message Should not contain a date, just the system specific info. |
|
84 | + * @return OperationResult |
|
85 | + */ |
|
86 | 86 | public function makeSuccess(string $message, int $code=0) : OperationResult |
87 | 87 | { |
88 | 88 | return $this->setMessage($message, $code, true); |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Sets the result as an error. |
|
93 | - * |
|
94 | - * @param string $message Should be as detailed as possible. |
|
95 | - * @return OperationResult |
|
96 | - */ |
|
91 | + /** |
|
92 | + * Sets the result as an error. |
|
93 | + * |
|
94 | + * @param string $message Should be as detailed as possible. |
|
95 | + * @return OperationResult |
|
96 | + */ |
|
97 | 97 | public function makeError(string $message, int $code=0) : OperationResult |
98 | 98 | { |
99 | 99 | return $this->setMessage($message, $code, false); |
@@ -108,21 +108,21 @@ discard block |
||
108 | 108 | return $this; |
109 | 109 | } |
110 | 110 | |
111 | - /** |
|
112 | - * Retrieves the error message, if an error occurred. |
|
113 | - * |
|
114 | - * @return string The error message, or an empty string if no error occurred. |
|
115 | - */ |
|
111 | + /** |
|
112 | + * Retrieves the error message, if an error occurred. |
|
113 | + * |
|
114 | + * @return string The error message, or an empty string if no error occurred. |
|
115 | + */ |
|
116 | 116 | public function getErrorMessage() : string |
117 | 117 | { |
118 | 118 | return $this->getMessage(false); |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Retrieves the success message, if one has been provided. |
|
123 | - * |
|
124 | - * @return string |
|
125 | - */ |
|
121 | + /** |
|
122 | + * Retrieves the success message, if one has been provided. |
|
123 | + * |
|
124 | + * @return string |
|
125 | + */ |
|
126 | 126 | public function getSuccessMessage() : string |
127 | 127 | { |
128 | 128 | return $this->getMessage(true); |
@@ -87,37 +87,37 @@ |
||
87 | 87 | */ |
88 | 88 | interface Interface_Classable |
89 | 89 | { |
90 | - /** |
|
91 | - * @param string $name |
|
92 | - * @return $this |
|
93 | - */ |
|
90 | + /** |
|
91 | + * @param string $name |
|
92 | + * @return $this |
|
93 | + */ |
|
94 | 94 | public function addClass(string $name); |
95 | 95 | |
96 | - /** |
|
97 | - * @param array $names |
|
98 | - * @return $this |
|
99 | - */ |
|
96 | + /** |
|
97 | + * @param array $names |
|
98 | + * @return $this |
|
99 | + */ |
|
100 | 100 | public function addClasses(array $names); |
101 | 101 | |
102 | - /** |
|
103 | - * @param string $name |
|
104 | - * @return bool |
|
105 | - */ |
|
102 | + /** |
|
103 | + * @param string $name |
|
104 | + * @return bool |
|
105 | + */ |
|
106 | 106 | public function hasClass(string $name) : bool; |
107 | 107 | |
108 | - /** |
|
109 | - * @param string $name |
|
110 | - * @return $this |
|
111 | - */ |
|
108 | + /** |
|
109 | + * @param string $name |
|
110 | + * @return $this |
|
111 | + */ |
|
112 | 112 | public function removeClass(string $name); |
113 | 113 | |
114 | - /** |
|
115 | - * @return array |
|
116 | - */ |
|
114 | + /** |
|
115 | + * @return array |
|
116 | + */ |
|
117 | 117 | public function getClasses() : array; |
118 | 118 | |
119 | - /** |
|
120 | - * @return string |
|
121 | - */ |
|
119 | + /** |
|
120 | + * @return string |
|
121 | + */ |
|
122 | 122 | public function classesToString() : string; |
123 | 123 | } |
@@ -26,18 +26,18 @@ discard block |
||
26 | 26 | */ |
27 | 27 | trait Traits_Optionable |
28 | 28 | { |
29 | - /** |
|
30 | - * @var array |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var array |
|
31 | + */ |
|
32 | 32 | protected $options; |
33 | 33 | |
34 | - /** |
|
35 | - * Sets an option to the specified value. This can be any |
|
36 | - * kind of variable type, including objects, as needed. |
|
37 | - * |
|
38 | - * @param string $name |
|
39 | - * @param mixed $value |
|
40 | - */ |
|
34 | + /** |
|
35 | + * Sets an option to the specified value. This can be any |
|
36 | + * kind of variable type, including objects, as needed. |
|
37 | + * |
|
38 | + * @param string $name |
|
39 | + * @param mixed $value |
|
40 | + */ |
|
41 | 41 | public function setOption(string $name, $value) |
42 | 42 | { |
43 | 43 | if(!isset($this->options)) { |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | return $this; |
49 | 49 | } |
50 | 50 | |
51 | - /** |
|
52 | - * Sets a collection of options at once, from an |
|
53 | - * associative array. |
|
54 | - * |
|
55 | - * @param array $options |
|
56 | - */ |
|
51 | + /** |
|
52 | + * Sets a collection of options at once, from an |
|
53 | + * associative array. |
|
54 | + * |
|
55 | + * @param array $options |
|
56 | + */ |
|
57 | 57 | public function setOptions(array $options) |
58 | 58 | { |
59 | 59 | foreach($options as $name => $value) { |
@@ -63,16 +63,16 @@ discard block |
||
63 | 63 | return $this; |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Retrieves an option's value. |
|
68 | - * |
|
69 | - * NOTE: Use the specialized type getters to ensure an option |
|
70 | - * contains the expected type (for ex. getArrayOption()). |
|
71 | - * |
|
72 | - * @param string $name |
|
73 | - * @param mixed $default The default value to return if the option does not exist. |
|
74 | - * @return mixed |
|
75 | - */ |
|
66 | + /** |
|
67 | + * Retrieves an option's value. |
|
68 | + * |
|
69 | + * NOTE: Use the specialized type getters to ensure an option |
|
70 | + * contains the expected type (for ex. getArrayOption()). |
|
71 | + * |
|
72 | + * @param string $name |
|
73 | + * @param mixed $default The default value to return if the option does not exist. |
|
74 | + * @return mixed |
|
75 | + */ |
|
76 | 76 | public function getOption(string $name, $default=null) |
77 | 77 | { |
78 | 78 | if(!isset($this->options)) { |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | return $default; |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Enforces that the option value is a string. Numbers are converted |
|
91 | - * to string, strings are passed through, and all other types will |
|
92 | - * return the default value. The default value is also returned if |
|
93 | - * the string is empty. |
|
94 | - * |
|
95 | - * @param string $name |
|
96 | - * @param string $default Used if the option does not exist, is invalid, or empty. |
|
97 | - * @return string |
|
98 | - */ |
|
89 | + /** |
|
90 | + * Enforces that the option value is a string. Numbers are converted |
|
91 | + * to string, strings are passed through, and all other types will |
|
92 | + * return the default value. The default value is also returned if |
|
93 | + * the string is empty. |
|
94 | + * |
|
95 | + * @param string $name |
|
96 | + * @param string $default Used if the option does not exist, is invalid, or empty. |
|
97 | + * @return string |
|
98 | + */ |
|
99 | 99 | public function getStringOption(string $name, string $default='') : string |
100 | 100 | { |
101 | 101 | $value = $this->getOption($name, false); |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | return $default; |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Treats the option value as a boolean value: will return |
|
112 | - * true if the value actually is a boolean true. |
|
113 | - * |
|
114 | - * NOTE: boolean string representations are not accepted. |
|
115 | - * |
|
116 | - * @param string $name |
|
117 | - * @return bool |
|
118 | - */ |
|
110 | + /** |
|
111 | + * Treats the option value as a boolean value: will return |
|
112 | + * true if the value actually is a boolean true. |
|
113 | + * |
|
114 | + * NOTE: boolean string representations are not accepted. |
|
115 | + * |
|
116 | + * @param string $name |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | 119 | public function getBoolOption(string $name, bool $default=false) : bool |
120 | 120 | { |
121 | 121 | if($this->getOption($name) === true) { |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | return $default; |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Treats the option value as an integer value: will return |
|
130 | - * valid integer values (also from integer strings), or the |
|
131 | - * default value otherwise. |
|
132 | - * |
|
133 | - * @param string $name |
|
134 | - * @param int $default |
|
135 | - * @return int |
|
136 | - */ |
|
128 | + /** |
|
129 | + * Treats the option value as an integer value: will return |
|
130 | + * valid integer values (also from integer strings), or the |
|
131 | + * default value otherwise. |
|
132 | + * |
|
133 | + * @param string $name |
|
134 | + * @param int $default |
|
135 | + * @return int |
|
136 | + */ |
|
137 | 137 | public function getIntOption(string $name, int $default=0) : int |
138 | 138 | { |
139 | 139 | $value = $this->getOption($name); |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | return $default; |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Treats an option as an array, and returns its value |
|
149 | - * only if it contains an array - otherwise, an empty |
|
150 | - * array is returned. |
|
151 | - * |
|
152 | - * @param string $name |
|
153 | - * @return array |
|
154 | - */ |
|
147 | + /** |
|
148 | + * Treats an option as an array, and returns its value |
|
149 | + * only if it contains an array - otherwise, an empty |
|
150 | + * array is returned. |
|
151 | + * |
|
152 | + * @param string $name |
|
153 | + * @return array |
|
154 | + */ |
|
155 | 155 | public function getArrayOption(string $name) : array |
156 | 156 | { |
157 | 157 | $val = $this->getOption($name); |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | return array(); |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Checks whether the specified option exists - even |
|
167 | - * if it has a NULL value. |
|
168 | - * |
|
169 | - * @param string $name |
|
170 | - * @return bool |
|
171 | - */ |
|
165 | + /** |
|
166 | + * Checks whether the specified option exists - even |
|
167 | + * if it has a NULL value. |
|
168 | + * |
|
169 | + * @param string $name |
|
170 | + * @return bool |
|
171 | + */ |
|
172 | 172 | public function hasOption(string $name) : bool |
173 | 173 | { |
174 | 174 | if(!isset($this->options)) { |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | return array_key_exists($name, $this->options); |
179 | 179 | } |
180 | 180 | |
181 | - /** |
|
182 | - * Returns all options in one associative array. |
|
183 | - * @return array |
|
184 | - */ |
|
181 | + /** |
|
182 | + * Returns all options in one associative array. |
|
183 | + * @return array |
|
184 | + */ |
|
185 | 185 | public function getOptions() : array |
186 | 186 | { |
187 | 187 | if(!isset($this->options)) { |
@@ -191,24 +191,24 @@ discard block |
||
191 | 191 | return $this->options; |
192 | 192 | } |
193 | 193 | |
194 | - /** |
|
195 | - * Checks whether the option's value is the one specified. |
|
196 | - * |
|
197 | - * @param string $name |
|
198 | - * @param mixed $value |
|
199 | - * @return bool |
|
200 | - */ |
|
194 | + /** |
|
195 | + * Checks whether the option's value is the one specified. |
|
196 | + * |
|
197 | + * @param string $name |
|
198 | + * @param mixed $value |
|
199 | + * @return bool |
|
200 | + */ |
|
201 | 201 | public function isOption(string $name, $value) : bool |
202 | 202 | { |
203 | 203 | return $this->getOption($name) === $value; |
204 | 204 | } |
205 | 205 | |
206 | - /** |
|
207 | - * Retrieves the default available options as an |
|
208 | - * associative array with option name => value pairs. |
|
209 | - * |
|
210 | - * @return array |
|
211 | - */ |
|
206 | + /** |
|
207 | + * Retrieves the default available options as an |
|
208 | + * associative array with option name => value pairs. |
|
209 | + * |
|
210 | + * @return array |
|
211 | + */ |
|
212 | 212 | abstract public function getDefaultOptions() : array; |
213 | 213 | } |
214 | 214 | |
@@ -226,24 +226,24 @@ discard block |
||
226 | 226 | */ |
227 | 227 | interface Interface_Optionable |
228 | 228 | { |
229 | - /** |
|
230 | - * @param string $name |
|
231 | - * @param mixed $value |
|
232 | - * @return $this |
|
233 | - */ |
|
229 | + /** |
|
230 | + * @param string $name |
|
231 | + * @param mixed $value |
|
232 | + * @return $this |
|
233 | + */ |
|
234 | 234 | function setOption(string $name, $value); |
235 | 235 | |
236 | - /** |
|
237 | - * @param string $name |
|
238 | - * @param mixed $default |
|
239 | - * @return $this |
|
240 | - */ |
|
236 | + /** |
|
237 | + * @param string $name |
|
238 | + * @param mixed $default |
|
239 | + * @return $this |
|
240 | + */ |
|
241 | 241 | function getOption(string $name, $default=null); |
242 | 242 | |
243 | - /** |
|
244 | - * @param array $options |
|
245 | - * @return $this |
|
246 | - */ |
|
243 | + /** |
|
244 | + * @param array $options |
|
245 | + * @return $this |
|
246 | + */ |
|
247 | 247 | function setOptions(array $options); |
248 | 248 | function getOptions() : array; |
249 | 249 | function isOption(string $name, $value) : bool; |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class URLInfo_Highlighter |
22 | 22 | { |
23 | - /** |
|
24 | - * @var URLInfo |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var URLInfo |
|
25 | + */ |
|
26 | 26 | protected $info; |
27 | 27 | |
28 | 28 | public function __construct(URLInfo $info) |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | ); |
159 | 159 | } |
160 | 160 | |
161 | - /** |
|
162 | - * Fetches all parameters in the URL, regardless of |
|
163 | - * whether parameter exclusion is enabled, so they |
|
164 | - * can be highlighted is need be. |
|
165 | - * |
|
166 | - * @return array |
|
167 | - */ |
|
161 | + /** |
|
162 | + * Fetches all parameters in the URL, regardless of |
|
163 | + * whether parameter exclusion is enabled, so they |
|
164 | + * can be highlighted is need be. |
|
165 | + * |
|
166 | + * @return array |
|
167 | + */ |
|
168 | 168 | protected function resolveParams() : array |
169 | 169 | { |
170 | 170 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -38,24 +38,24 @@ discard block |
||
38 | 38 | */ |
39 | 39 | class NumberInfo |
40 | 40 | { |
41 | - /** |
|
42 | - * @var mixed |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var mixed |
|
43 | + */ |
|
44 | 44 | protected $rawValue; |
45 | 45 | |
46 | - /** |
|
47 | - * @var array |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var array |
|
48 | + */ |
|
49 | 49 | protected $info; |
50 | 50 | |
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | 54 | protected $empty = false; |
55 | 55 | |
56 | - /** |
|
57 | - * @var array |
|
58 | - */ |
|
56 | + /** |
|
57 | + * @var array |
|
58 | + */ |
|
59 | 59 | protected $knownUnits = array( |
60 | 60 | '%' => true, |
61 | 61 | 'rem' => true, |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | return $this; |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Retrieves the raw, internal information array resulting |
|
100 | - * from the parsing of the number. |
|
101 | - * |
|
102 | - * @return array |
|
103 | - */ |
|
98 | + /** |
|
99 | + * Retrieves the raw, internal information array resulting |
|
100 | + * from the parsing of the number. |
|
101 | + * |
|
102 | + * @return array |
|
103 | + */ |
|
104 | 104 | public function getRawInfo() : array |
105 | 105 | { |
106 | 106 | return $this->info; |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Whether the number was empty (null or empty string). |
|
111 | - * @return boolean |
|
112 | - */ |
|
109 | + /** |
|
110 | + * Whether the number was empty (null or empty string). |
|
111 | + * @return boolean |
|
112 | + */ |
|
113 | 113 | public function isEmpty() : bool |
114 | 114 | { |
115 | 115 | return $this->empty; |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | return $cache[$key]; |
533 | 533 | } |
534 | 534 | |
535 | - /** |
|
536 | - * Parses a string number notation with units included, e.g. 14px, 50%... |
|
537 | - * |
|
538 | - * @param string $test |
|
539 | - * @return array |
|
540 | - */ |
|
535 | + /** |
|
536 | + * Parses a string number notation with units included, e.g. 14px, 50%... |
|
537 | + * |
|
538 | + * @param string $test |
|
539 | + * @return array |
|
540 | + */ |
|
541 | 541 | private function parseStringValue(string $test) : array |
542 | 542 | { |
543 | 543 | $number = null; |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | return $this->filterInfo($result); |
589 | 589 | } |
590 | 590 | |
591 | - /** |
|
592 | - * Attempts to determine what kind of units are specified |
|
593 | - * in the string. Returns NULL if none could be matched. |
|
594 | - * |
|
595 | - * @param string $value |
|
596 | - * @return array|NULL |
|
597 | - */ |
|
591 | + /** |
|
592 | + * Attempts to determine what kind of units are specified |
|
593 | + * in the string. Returns NULL if none could be matched. |
|
594 | + * |
|
595 | + * @param string $value |
|
596 | + * @return array|NULL |
|
597 | + */ |
|
598 | 598 | private function findUnits(string $value) : ?array |
599 | 599 | { |
600 | 600 | $vlength = strlen($value); |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | return null; |
623 | 623 | } |
624 | 624 | |
625 | - /** |
|
626 | - * Creates the cache key for the specified value. |
|
627 | - * |
|
628 | - * @param mixed $value |
|
629 | - * @return string |
|
630 | - */ |
|
625 | + /** |
|
626 | + * Creates the cache key for the specified value. |
|
627 | + * |
|
628 | + * @param mixed $value |
|
629 | + * @return string |
|
630 | + */ |
|
631 | 631 | private function createValueKey($value) : string |
632 | 632 | { |
633 | 633 | if(!is_string($value) && !is_numeric($value)) |
@@ -640,59 +640,59 @@ discard block |
||
640 | 640 | |
641 | 641 | protected $postProcess = false; |
642 | 642 | |
643 | - /** |
|
644 | - * Called if explicitly enabled: allows filtering the |
|
645 | - * number after the detection process has completed. |
|
646 | - * |
|
647 | - * @param string|NULL $number The adjusted number |
|
648 | - * @param string $originalString The original value before it was parsed |
|
649 | - * @return mixed |
|
650 | - */ |
|
643 | + /** |
|
644 | + * Called if explicitly enabled: allows filtering the |
|
645 | + * number after the detection process has completed. |
|
646 | + * |
|
647 | + * @param string|NULL $number The adjusted number |
|
648 | + * @param string $originalString The original value before it was parsed |
|
649 | + * @return mixed |
|
650 | + */ |
|
651 | 651 | protected function postProcess(?string $number, /** @scrutinizer ignore-unused */ string $originalString) |
652 | 652 | { |
653 | 653 | return $number; |
654 | 654 | } |
655 | 655 | |
656 | - /** |
|
657 | - * Filters the value before it is parsed, but only if it is a string. |
|
658 | - * |
|
659 | - * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
660 | - * the the values. An example of a use case would be a preprocessor for |
|
661 | - * variables in a templating system. |
|
662 | - * |
|
663 | - * @param string $trimmedString The trimmed value. |
|
664 | - * @param array $cache The internal values cache array. |
|
665 | - * @param string $originalValue The original value that the NumberInfo was created for. |
|
666 | - * @return string |
|
667 | - * |
|
668 | - * @see NumberInfo::enablePostProcess() |
|
669 | - */ |
|
656 | + /** |
|
657 | + * Filters the value before it is parsed, but only if it is a string. |
|
658 | + * |
|
659 | + * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
660 | + * the the values. An example of a use case would be a preprocessor for |
|
661 | + * variables in a templating system. |
|
662 | + * |
|
663 | + * @param string $trimmedString The trimmed value. |
|
664 | + * @param array $cache The internal values cache array. |
|
665 | + * @param string $originalValue The original value that the NumberInfo was created for. |
|
666 | + * @return string |
|
667 | + * |
|
668 | + * @see NumberInfo::enablePostProcess() |
|
669 | + */ |
|
670 | 670 | protected function preProcess(string $trimmedString, /** @scrutinizer ignore-unused */ array &$cache, /** @scrutinizer ignore-unused */ string $originalValue) : string |
671 | 671 | { |
672 | 672 | return str_replace(',', '.', $trimmedString); |
673 | 673 | } |
674 | 674 | |
675 | - /** |
|
676 | - * Enables the post processing so the postProcess method gets called. |
|
677 | - * This should be called in the {@link NumberInfo::preProcess()} |
|
678 | - * method as needed. |
|
679 | - * |
|
680 | - * @return NumberInfo |
|
681 | - * @see NumberInfo::postProcess() |
|
682 | - */ |
|
675 | + /** |
|
676 | + * Enables the post processing so the postProcess method gets called. |
|
677 | + * This should be called in the {@link NumberInfo::preProcess()} |
|
678 | + * method as needed. |
|
679 | + * |
|
680 | + * @return NumberInfo |
|
681 | + * @see NumberInfo::postProcess() |
|
682 | + */ |
|
683 | 683 | protected function enablePostProcess() : NumberInfo |
684 | 684 | { |
685 | 685 | $this->postProcess = true; |
686 | 686 | return $this; |
687 | 687 | } |
688 | 688 | |
689 | - /** |
|
690 | - * Filters the number info array to adjust the units |
|
691 | - * and number according to the required rules. |
|
692 | - * |
|
693 | - * @param array $info |
|
694 | - * @return array |
|
695 | - */ |
|
689 | + /** |
|
690 | + * Filters the number info array to adjust the units |
|
691 | + * and number according to the required rules. |
|
692 | + * |
|
693 | + * @param array $info |
|
694 | + * @return array |
|
695 | + */ |
|
696 | 696 | protected function filterInfo(array $info) : array |
697 | 697 | { |
698 | 698 | $useUnits = 'px'; |
@@ -27,16 +27,16 @@ |
||
27 | 27 | |
28 | 28 | } |
29 | 29 | |
30 | - /** |
|
31 | - * We parse the query string ourselves, because the PHP implementation |
|
32 | - * of parse_str has limitations that do not apply to query strings. This |
|
33 | - * is due to the fact that parse_str has to create PHP-compatible variable |
|
34 | - * names from the parameters. URL parameters simply allow way more things |
|
35 | - * than PHP variable names. |
|
36 | - * |
|
37 | - * @param string $queryString |
|
38 | - * @return array |
|
39 | - */ |
|
30 | + /** |
|
31 | + * We parse the query string ourselves, because the PHP implementation |
|
32 | + * of parse_str has limitations that do not apply to query strings. This |
|
33 | + * is due to the fact that parse_str has to create PHP-compatible variable |
|
34 | + * names from the parameters. URL parameters simply allow way more things |
|
35 | + * than PHP variable names. |
|
36 | + * |
|
37 | + * @param string $queryString |
|
38 | + * @return array |
|
39 | + */ |
|
40 | 40 | public function parse(string $queryString) : array |
41 | 41 | { |
42 | 42 | // allow HTML entities notation |
@@ -39,42 +39,42 @@ discard block |
||
39 | 39 | const TYPE_PHONE = 'phone'; |
40 | 40 | const TYPE_URL = 'url'; |
41 | 41 | |
42 | - /** |
|
43 | - * The original URL that was passed to the constructor. |
|
44 | - * @var string |
|
45 | - */ |
|
42 | + /** |
|
43 | + * The original URL that was passed to the constructor. |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $rawURL; |
47 | 47 | |
48 | - /** |
|
49 | - * @var array |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var array |
|
50 | + */ |
|
51 | 51 | protected $info; |
52 | 52 | |
53 | - /** |
|
54 | - * @var string[] |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var string[] |
|
55 | + */ |
|
56 | 56 | protected $excludedParams = array(); |
57 | 57 | |
58 | - /** |
|
59 | - * @var bool |
|
60 | - * @see URLInfo::setParamExclusion() |
|
61 | - */ |
|
58 | + /** |
|
59 | + * @var bool |
|
60 | + * @see URLInfo::setParamExclusion() |
|
61 | + */ |
|
62 | 62 | protected $paramExclusion = false; |
63 | 63 | |
64 | - /** |
|
65 | - * @var array |
|
66 | - * @see URLInfo::getTypeLabel() |
|
67 | - */ |
|
64 | + /** |
|
65 | + * @var array |
|
66 | + * @see URLInfo::getTypeLabel() |
|
67 | + */ |
|
68 | 68 | protected static $typeLabels; |
69 | 69 | |
70 | - /** |
|
71 | - * @var bool |
|
72 | - */ |
|
70 | + /** |
|
71 | + * @var bool |
|
72 | + */ |
|
73 | 73 | protected $highlightExcluded = false; |
74 | 74 | |
75 | - /** |
|
76 | - * @var array |
|
77 | - */ |
|
75 | + /** |
|
76 | + * @var array |
|
77 | + */ |
|
78 | 78 | protected $infoKeys = array( |
79 | 79 | 'scheme', |
80 | 80 | 'host', |
@@ -86,24 +86,24 @@ discard block |
||
86 | 86 | 'fragment' |
87 | 87 | ); |
88 | 88 | |
89 | - /** |
|
90 | - * @var string |
|
91 | - */ |
|
89 | + /** |
|
90 | + * @var string |
|
91 | + */ |
|
92 | 92 | protected $url; |
93 | 93 | |
94 | - /** |
|
95 | - * @var URLInfo_Parser |
|
96 | - */ |
|
94 | + /** |
|
95 | + * @var URLInfo_Parser |
|
96 | + */ |
|
97 | 97 | protected $parser; |
98 | 98 | |
99 | - /** |
|
100 | - * @var URLInfo_Normalizer |
|
101 | - */ |
|
99 | + /** |
|
100 | + * @var URLInfo_Normalizer |
|
101 | + */ |
|
102 | 102 | protected $normalizer; |
103 | 103 | |
104 | - /** |
|
105 | - * @var bool |
|
106 | - */ |
|
104 | + /** |
|
105 | + * @var bool |
|
106 | + */ |
|
107 | 107 | protected $encodeUTFChars = false; |
108 | 108 | |
109 | 109 | public function __construct(string $url) |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | $this->info = $this->parser->getInfo(); |
121 | 121 | } |
122 | 122 | |
123 | - /** |
|
124 | - * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
125 | - * Default is to leave them as-is for better readability, since |
|
126 | - * browsers handle this well. |
|
127 | - * |
|
128 | - * @param bool $enabled |
|
129 | - * @return URLInfo |
|
130 | - */ |
|
123 | + /** |
|
124 | + * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
125 | + * Default is to leave them as-is for better readability, since |
|
126 | + * browsers handle this well. |
|
127 | + * |
|
128 | + * @param bool $enabled |
|
129 | + * @return URLInfo |
|
130 | + */ |
|
131 | 131 | public function setUTFEncoding(bool $enabled=true) : URLInfo |
132 | 132 | { |
133 | 133 | if($this->encodeUTFChars !== $enabled) |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | return $this->encodeUTFChars; |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Filters an URL: removes control characters and the |
|
149 | - * like to have a clean URL to work with. |
|
150 | - * |
|
151 | - * @param string $url |
|
152 | - * @return string |
|
153 | - */ |
|
147 | + /** |
|
148 | + * Filters an URL: removes control characters and the |
|
149 | + * like to have a clean URL to work with. |
|
150 | + * |
|
151 | + * @param string $url |
|
152 | + * @return string |
|
153 | + */ |
|
154 | 154 | public static function filterURL(string $url) |
155 | 155 | { |
156 | 156 | return URLInfo_Filter::filter($url); |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | return $this->info['type'] === self::TYPE_PHONE; |
181 | 181 | } |
182 | 182 | |
183 | - /** |
|
184 | - * Whether the URL is a regular URL, not one of the |
|
185 | - * other types like a phone number or email address. |
|
186 | - * |
|
187 | - * @return bool |
|
188 | - */ |
|
183 | + /** |
|
184 | + * Whether the URL is a regular URL, not one of the |
|
185 | + * other types like a phone number or email address. |
|
186 | + * |
|
187 | + * @return bool |
|
188 | + */ |
|
189 | 189 | public function isURL() : bool |
190 | 190 | { |
191 | 191 | $host = $this->getHost(); |
@@ -197,20 +197,20 @@ discard block |
||
197 | 197 | return $this->parser->isValid(); |
198 | 198 | } |
199 | 199 | |
200 | - /** |
|
201 | - * Retrieves the host name, or an empty string if none is present. |
|
202 | - * |
|
203 | - * @return string |
|
204 | - */ |
|
200 | + /** |
|
201 | + * Retrieves the host name, or an empty string if none is present. |
|
202 | + * |
|
203 | + * @return string |
|
204 | + */ |
|
205 | 205 | public function getHost() : string |
206 | 206 | { |
207 | 207 | return $this->getInfoKey('host'); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Retrieves the path, or an empty string if none is present. |
|
212 | - * @return string |
|
213 | - */ |
|
210 | + /** |
|
211 | + * Retrieves the path, or an empty string if none is present. |
|
212 | + * @return string |
|
213 | + */ |
|
214 | 214 | public function getPath() : string |
215 | 215 | { |
216 | 216 | return $this->getInfoKey('path'); |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | return $this->getInfoKey('scheme'); |
227 | 227 | } |
228 | 228 | |
229 | - /** |
|
230 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
231 | - * @return int |
|
232 | - */ |
|
229 | + /** |
|
230 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
231 | + * @return int |
|
232 | + */ |
|
233 | 233 | public function getPort() : int |
234 | 234 | { |
235 | 235 | $port = $this->getInfoKey('port'); |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | return -1; |
242 | 242 | } |
243 | 243 | |
244 | - /** |
|
245 | - * Retrieves the raw query string, or an empty string if none is present. |
|
246 | - * |
|
247 | - * @return string |
|
248 | - * |
|
249 | - * @see URLInfo::getParams() |
|
250 | - */ |
|
244 | + /** |
|
245 | + * Retrieves the raw query string, or an empty string if none is present. |
|
246 | + * |
|
247 | + * @return string |
|
248 | + * |
|
249 | + * @see URLInfo::getParams() |
|
250 | + */ |
|
251 | 251 | public function getQuery() : string |
252 | 252 | { |
253 | 253 | return $this->getInfoKey('query'); |
@@ -263,20 +263,20 @@ discard block |
||
263 | 263 | return $this->getInfoKey('pass'); |
264 | 264 | } |
265 | 265 | |
266 | - /** |
|
267 | - * Whether the URL contains a port number. |
|
268 | - * @return bool |
|
269 | - */ |
|
266 | + /** |
|
267 | + * Whether the URL contains a port number. |
|
268 | + * @return bool |
|
269 | + */ |
|
270 | 270 | public function hasPort() : bool |
271 | 271 | { |
272 | 272 | return $this->getPort() !== -1; |
273 | 273 | } |
274 | 274 | |
275 | - /** |
|
276 | - * Alias for the hasParams() method. |
|
277 | - * @return bool |
|
278 | - * @see URLInfo::hasParams() |
|
279 | - */ |
|
275 | + /** |
|
276 | + * Alias for the hasParams() method. |
|
277 | + * @return bool |
|
278 | + * @see URLInfo::hasParams() |
|
279 | + */ |
|
280 | 280 | public function hasQuery() : bool |
281 | 281 | { |
282 | 282 | return $this->hasParams(); |
@@ -321,23 +321,23 @@ discard block |
||
321 | 321 | return ''; |
322 | 322 | } |
323 | 323 | |
324 | - /** |
|
325 | - * Retrieves a normalized URL: this ensures that all parameters |
|
326 | - * in the URL are always in the same order. |
|
327 | - * |
|
328 | - * @return string |
|
329 | - */ |
|
324 | + /** |
|
325 | + * Retrieves a normalized URL: this ensures that all parameters |
|
326 | + * in the URL are always in the same order. |
|
327 | + * |
|
328 | + * @return string |
|
329 | + */ |
|
330 | 330 | public function getNormalized() : string |
331 | 331 | { |
332 | 332 | return $this->normalize(true); |
333 | 333 | } |
334 | 334 | |
335 | - /** |
|
336 | - * Like getNormalized(), but if a username and password are present |
|
337 | - * in the URL, returns the URL without them. |
|
338 | - * |
|
339 | - * @return string |
|
340 | - */ |
|
335 | + /** |
|
336 | + * Like getNormalized(), but if a username and password are present |
|
337 | + * in the URL, returns the URL without them. |
|
338 | + * |
|
339 | + * @return string |
|
340 | + */ |
|
341 | 341 | public function getNormalizedWithoutAuth() : string |
342 | 342 | { |
343 | 343 | return $this->normalize(false); |
@@ -358,25 +358,25 @@ discard block |
||
358 | 358 | return $this->normalizer->normalize(); |
359 | 359 | } |
360 | 360 | |
361 | - /** |
|
362 | - * Creates a hash of the URL, which can be used for comparisons. |
|
363 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
364 | - * the same links with a different parameter order will have the |
|
365 | - * same hash. |
|
366 | - * |
|
367 | - * @return string |
|
368 | - */ |
|
361 | + /** |
|
362 | + * Creates a hash of the URL, which can be used for comparisons. |
|
363 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
364 | + * the same links with a different parameter order will have the |
|
365 | + * same hash. |
|
366 | + * |
|
367 | + * @return string |
|
368 | + */ |
|
369 | 369 | public function getHash() |
370 | 370 | { |
371 | 371 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
372 | 372 | } |
373 | 373 | |
374 | - /** |
|
375 | - * Highlights the URL using HTML tags with specific highlighting |
|
376 | - * class names. |
|
377 | - * |
|
378 | - * @return string Will return an empty string if the URL is not valid. |
|
379 | - */ |
|
374 | + /** |
|
375 | + * Highlights the URL using HTML tags with specific highlighting |
|
376 | + * class names. |
|
377 | + * |
|
378 | + * @return string Will return an empty string if the URL is not valid. |
|
379 | + */ |
|
380 | 380 | public function getHighlighted() : string |
381 | 381 | { |
382 | 382 | if(!$this->isValid()) { |
@@ -410,15 +410,15 @@ discard block |
||
410 | 410 | return count($params); |
411 | 411 | } |
412 | 412 | |
413 | - /** |
|
414 | - * Retrieves all parameters specified in the url, |
|
415 | - * if any, as an associative array. |
|
416 | - * |
|
417 | - * NOTE: Ignores parameters that have been added |
|
418 | - * to the excluded parameters list. |
|
419 | - * |
|
420 | - * @return array |
|
421 | - */ |
|
413 | + /** |
|
414 | + * Retrieves all parameters specified in the url, |
|
415 | + * if any, as an associative array. |
|
416 | + * |
|
417 | + * NOTE: Ignores parameters that have been added |
|
418 | + * to the excluded parameters list. |
|
419 | + * |
|
420 | + * @return array |
|
421 | + */ |
|
422 | 422 | public function getParams() : array |
423 | 423 | { |
424 | 424 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | return $keep; |
437 | 437 | } |
438 | 438 | |
439 | - /** |
|
440 | - * Retrieves the names of all parameters present in the URL, if any. |
|
441 | - * @return string[] |
|
442 | - */ |
|
439 | + /** |
|
440 | + * Retrieves the names of all parameters present in the URL, if any. |
|
441 | + * @return string[] |
|
442 | + */ |
|
443 | 443 | public function getParamNames() : array |
444 | 444 | { |
445 | 445 | $params = $this->getParams(); |
446 | 446 | return array_keys($params); |
447 | 447 | } |
448 | 448 | |
449 | - /** |
|
450 | - * Retrieves a specific parameter value from the URL. |
|
451 | - * |
|
452 | - * @param string $name |
|
453 | - * @return string The parameter value, or an empty string if it does not exist. |
|
454 | - */ |
|
449 | + /** |
|
450 | + * Retrieves a specific parameter value from the URL. |
|
451 | + * |
|
452 | + * @param string $name |
|
453 | + * @return string The parameter value, or an empty string if it does not exist. |
|
454 | + */ |
|
455 | 455 | public function getParam(string $name) : string |
456 | 456 | { |
457 | 457 | if(isset($this->info['params'][$name])) { |
@@ -461,16 +461,16 @@ discard block |
||
461 | 461 | return ''; |
462 | 462 | } |
463 | 463 | |
464 | - /** |
|
465 | - * Excludes an URL parameter entirely if present: |
|
466 | - * the parser will act as if the parameter was not |
|
467 | - * even present in the source URL, effectively |
|
468 | - * stripping it. |
|
469 | - * |
|
470 | - * @param string $name |
|
471 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
472 | - * @return URLInfo |
|
473 | - */ |
|
464 | + /** |
|
465 | + * Excludes an URL parameter entirely if present: |
|
466 | + * the parser will act as if the parameter was not |
|
467 | + * even present in the source URL, effectively |
|
468 | + * stripping it. |
|
469 | + * |
|
470 | + * @param string $name |
|
471 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
472 | + * @return URLInfo |
|
473 | + */ |
|
474 | 474 | public function excludeParam(string $name, string $reason) : URLInfo |
475 | 475 | { |
476 | 476 | if(!isset($this->excludedParams[$name])) |
@@ -523,25 +523,25 @@ discard block |
||
523 | 523 | return self::$typeLabels[$this->getType()]; |
524 | 524 | } |
525 | 525 | |
526 | - /** |
|
527 | - * Whether excluded parameters should be highlighted in |
|
528 | - * a different color in the URL when using the |
|
529 | - * {@link URLInfo::getHighlighted()} method. |
|
530 | - * |
|
531 | - * @param bool $highlight |
|
532 | - * @return URLInfo |
|
533 | - */ |
|
526 | + /** |
|
527 | + * Whether excluded parameters should be highlighted in |
|
528 | + * a different color in the URL when using the |
|
529 | + * {@link URLInfo::getHighlighted()} method. |
|
530 | + * |
|
531 | + * @param bool $highlight |
|
532 | + * @return URLInfo |
|
533 | + */ |
|
534 | 534 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
535 | 535 | { |
536 | 536 | $this->highlightExcluded = $highlight; |
537 | 537 | return $this; |
538 | 538 | } |
539 | 539 | |
540 | - /** |
|
541 | - * Returns an array with all relevant URL information. |
|
542 | - * |
|
543 | - * @return array |
|
544 | - */ |
|
540 | + /** |
|
541 | + * Returns an array with all relevant URL information. |
|
542 | + * |
|
543 | + * @return array |
|
544 | + */ |
|
545 | 545 | public function toArray() : array |
546 | 546 | { |
547 | 547 | return array( |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | return $this; |
586 | 586 | } |
587 | 587 | |
588 | - /** |
|
589 | - * Whether the parameter exclusion mode is enabled: |
|
590 | - * In this case, if any parameters have been added to the |
|
591 | - * exclusion list, all relevant methods will exclude these. |
|
592 | - * |
|
593 | - * @return bool |
|
594 | - */ |
|
588 | + /** |
|
589 | + * Whether the parameter exclusion mode is enabled: |
|
590 | + * In this case, if any parameters have been added to the |
|
591 | + * exclusion list, all relevant methods will exclude these. |
|
592 | + * |
|
593 | + * @return bool |
|
594 | + */ |
|
595 | 595 | public function isParamExclusionEnabled() : bool |
596 | 596 | { |
597 | 597 | return $this->paramExclusion; |
598 | 598 | } |
599 | 599 | |
600 | - /** |
|
601 | - * Checks whether the link contains any parameters that |
|
602 | - * are on the list of excluded parameters. |
|
603 | - * |
|
604 | - * @return bool |
|
605 | - */ |
|
600 | + /** |
|
601 | + * Checks whether the link contains any parameters that |
|
602 | + * are on the list of excluded parameters. |
|
603 | + * |
|
604 | + * @return bool |
|
605 | + */ |
|
606 | 606 | public function containsExcludedParams() : bool |
607 | 607 | { |
608 | 608 | if(empty($this->excludedParams)) { |
@@ -670,16 +670,16 @@ discard block |
||
670 | 670 | return $this->highlightExcluded; |
671 | 671 | } |
672 | 672 | |
673 | - /** |
|
674 | - * Checks if the URL exists, i.e. can be connected to. Will return |
|
675 | - * true if the returned HTTP status code is `200` or `302`. |
|
676 | - * |
|
677 | - * NOTE: If the target URL requires HTTP authentication, the username |
|
678 | - * and password should be integrated into the URL. |
|
679 | - * |
|
680 | - * @return bool |
|
681 | - * @throws BaseException |
|
682 | - */ |
|
673 | + /** |
|
674 | + * Checks if the URL exists, i.e. can be connected to. Will return |
|
675 | + * true if the returned HTTP status code is `200` or `302`. |
|
676 | + * |
|
677 | + * NOTE: If the target URL requires HTTP authentication, the username |
|
678 | + * and password should be integrated into the URL. |
|
679 | + * |
|
680 | + * @return bool |
|
681 | + * @throws BaseException |
|
682 | + */ |
|
683 | 683 | public function tryConnect(bool $verifySSL=true) : bool |
684 | 684 | { |
685 | 685 | requireCURL(); |