@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | - /** |
|
15 | - * @var VariableInfo |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var VariableInfo |
|
16 | + */ |
|
17 | 17 | protected $info; |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | protected $type; |
23 | 23 | |
24 | 24 | public function __construct(VariableInfo $info) |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | abstract protected function init(); |
33 | 33 | |
34 | - /** |
|
35 | - * Renders the value to the target format. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
34 | + /** |
|
35 | + * Renders the value to the target format. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | 39 | public function render() |
40 | 40 | { |
41 | 41 | return $this->_render(); |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class XMLHelper_Converter_Decorator implements \JsonSerializable |
23 | 23 | { |
24 | - /** |
|
25 | - * @var \SimpleXMLElement |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var \SimpleXMLElement |
|
26 | + */ |
|
27 | 27 | private $subject; |
28 | 28 | |
29 | 29 | const DEF_DEPTH = 512; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
34 | 34 | private $options = array( |
35 | 35 | '@attributes' => true, |
36 | 36 | '@text' => true, |
37 | 37 | 'depth' => self::DEF_DEPTH |
38 | 38 | ); |
39 | 39 | |
40 | - /** |
|
41 | - * @var array|string|null |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var array|string|null |
|
42 | + */ |
|
43 | 43 | protected $result = array(); |
44 | 44 | |
45 | 45 | public function __construct(\SimpleXMLElement $element) |
@@ -47,36 +47,36 @@ discard block |
||
47 | 47 | $this->subject = $element; |
48 | 48 | } |
49 | 49 | |
50 | - /** |
|
51 | - * Whether to use the `@attributes` key to store element attributes. |
|
52 | - * |
|
53 | - * @param bool $bool |
|
54 | - * @return XMLHelper_Converter_Decorator |
|
55 | - */ |
|
50 | + /** |
|
51 | + * Whether to use the `@attributes` key to store element attributes. |
|
52 | + * |
|
53 | + * @param bool $bool |
|
54 | + * @return XMLHelper_Converter_Decorator |
|
55 | + */ |
|
56 | 56 | public function useAttributes(bool $bool) : XMLHelper_Converter_Decorator |
57 | 57 | { |
58 | 58 | $this->options['@attributes'] = (bool)$bool; |
59 | 59 | return $this; |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Whether to use the `@text` key to store the node text. |
|
64 | - * |
|
65 | - * @param bool $bool |
|
66 | - * @return XMLHelper_Converter_Decorator |
|
67 | - */ |
|
62 | + /** |
|
63 | + * Whether to use the `@text` key to store the node text. |
|
64 | + * |
|
65 | + * @param bool $bool |
|
66 | + * @return XMLHelper_Converter_Decorator |
|
67 | + */ |
|
68 | 68 | public function useText(bool $bool) : XMLHelper_Converter_Decorator |
69 | 69 | { |
70 | 70 | $this->options['@text'] = (bool)$bool; |
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Set the maximum depth to parse in the document. |
|
76 | - * |
|
77 | - * @param int $depth |
|
78 | - * @return XMLHelper_Converter_Decorator |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Set the maximum depth to parse in the document. |
|
76 | + * |
|
77 | + * @param int $depth |
|
78 | + * @return XMLHelper_Converter_Decorator |
|
79 | + */ |
|
80 | 80 | public function setDepth(int $depth) : XMLHelper_Converter_Decorator |
81 | 81 | { |
82 | 82 | $this->options['depth'] = (int)max(0, $depth); |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | |
108 | 108 | protected function detectAttributes() |
109 | 109 | { |
110 | - if(!$this->options['@attributes']) { |
|
110 | + if (!$this->options['@attributes']) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | 114 | $attributes = $this->subject->attributes(); |
115 | 115 | |
116 | - if(!empty($attributes)) |
|
116 | + if (!empty($attributes)) |
|
117 | 117 | { |
118 | 118 | $this->result['@attributes'] = array_map('strval', iterator_to_array($attributes)); |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $children = $this->subject; |
125 | 125 | $depth = $this->options['depth'] - 1; |
126 | 126 | |
127 | - if($depth <= 0) |
|
127 | + if ($depth <= 0) |
|
128 | 128 | { |
129 | 129 | $children = []; |
130 | 130 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | $decorator->options = ['depth' => $depth] + $this->options; |
139 | 139 | |
140 | - if(isset($this->result[$name])) |
|
140 | + if (isset($this->result[$name])) |
|
141 | 141 | { |
142 | - if(!is_array($this->result[$name])) |
|
142 | + if (!is_array($this->result[$name])) |
|
143 | 143 | { |
144 | 144 | $this->result[$name] = [$this->result[$name]]; |
145 | 145 | } |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | // json encode non-whitespace element simplexml text values. |
159 | 159 | $text = trim((string)$this->subject); |
160 | 160 | |
161 | - if(strlen($text)) |
|
161 | + if (strlen($text)) |
|
162 | 162 | { |
163 | - if($this->options['@text']) |
|
163 | + if ($this->options['@text']) |
|
164 | 164 | { |
165 | 165 | $this->result['@text'] = $text; |
166 | 166 | } |
@@ -145,8 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | $this->result[$name][] = $decorator; |
148 | - } |
|
149 | - else |
|
148 | + } else |
|
150 | 149 | { |
151 | 150 | $this->result[$name] = $decorator; |
152 | 151 | } |
@@ -163,8 +162,7 @@ discard block |
||
163 | 162 | if($this->options['@text']) |
164 | 163 | { |
165 | 164 | $this->result['@text'] = $text; |
166 | - } |
|
167 | - else |
|
165 | + } else |
|
168 | 166 | { |
169 | 167 | $this->result = $text; |
170 | 168 | } |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | * @param mixed $value |
17 | 17 | * @return \AppUtils\NumberInfo |
18 | 18 | */ |
19 | -function parseNumber($value, $forceNew=false) |
|
19 | +function parseNumber($value, $forceNew = false) |
|
20 | 20 | { |
21 | - if($value instanceof NumberInfo && $forceNew !== true) { |
|
21 | + if ($value instanceof NumberInfo && $forceNew !== true) { |
|
22 | 22 | return $value; |
23 | 23 | } |
24 | 24 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $args = func_get_args(); |
100 | 100 | |
101 | 101 | // is the localization package installed? |
102 | - if(class_exists('\AppLocalize\Localization')) |
|
102 | + if (class_exists('\AppLocalize\Localization')) |
|
103 | 103 | { |
104 | 104 | return call_user_func_array('\AppLocalize\t', $args); |
105 | 105 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | function requireCURL() : void |
119 | 119 | { |
120 | - if(function_exists('curl_init')) { |
|
120 | + if (function_exists('curl_init')) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function init() |
137 | 137 | { |
138 | - if(!class_exists('\AppLocalize\Localization')) { |
|
138 | + if (!class_exists('\AppLocalize\Localization')) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 |
@@ -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,19 +86,19 @@ 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 | 104 | public function __construct(string $url) |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $this->info = $this->parser->getInfo(); |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Filters an URL: removes control characters and the |
|
115 | - * like to have a clean URL to work with. |
|
116 | - * |
|
117 | - * @param string $url |
|
118 | - * @return string |
|
119 | - */ |
|
113 | + /** |
|
114 | + * Filters an URL: removes control characters and the |
|
115 | + * like to have a clean URL to work with. |
|
116 | + * |
|
117 | + * @param string $url |
|
118 | + * @return string |
|
119 | + */ |
|
120 | 120 | public static function filterURL(string $url) |
121 | 121 | { |
122 | 122 | return URLInfo_Filter::filter($url); |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | return $this->info['type'] === self::TYPE_PHONE; |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Whether the URL is a regular URL, not one of the |
|
151 | - * other types like a phone number or email address. |
|
152 | - * |
|
153 | - * @return bool |
|
154 | - */ |
|
149 | + /** |
|
150 | + * Whether the URL is a regular URL, not one of the |
|
151 | + * other types like a phone number or email address. |
|
152 | + * |
|
153 | + * @return bool |
|
154 | + */ |
|
155 | 155 | public function isURL() : bool |
156 | 156 | { |
157 | 157 | $host = $this->getHost(); |
@@ -163,20 +163,20 @@ discard block |
||
163 | 163 | return $this->parser->isValid(); |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Retrieves the host name, or an empty string if none is present. |
|
168 | - * |
|
169 | - * @return string |
|
170 | - */ |
|
166 | + /** |
|
167 | + * Retrieves the host name, or an empty string if none is present. |
|
168 | + * |
|
169 | + * @return string |
|
170 | + */ |
|
171 | 171 | public function getHost() : string |
172 | 172 | { |
173 | 173 | return $this->getInfoKey('host'); |
174 | 174 | } |
175 | 175 | |
176 | - /** |
|
177 | - * Retrieves the path, or an empty string if none is present. |
|
178 | - * @return string |
|
179 | - */ |
|
176 | + /** |
|
177 | + * Retrieves the path, or an empty string if none is present. |
|
178 | + * @return string |
|
179 | + */ |
|
180 | 180 | public function getPath() : string |
181 | 181 | { |
182 | 182 | return $this->getInfoKey('path'); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | return $this->getInfoKey('scheme'); |
193 | 193 | } |
194 | 194 | |
195 | - /** |
|
196 | - * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
197 | - * @return int |
|
198 | - */ |
|
195 | + /** |
|
196 | + * Retrieves the port specified in the URL, or -1 if none is preseent. |
|
197 | + * @return int |
|
198 | + */ |
|
199 | 199 | public function getPort() : int |
200 | 200 | { |
201 | 201 | $port = $this->getInfoKey('port'); |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | return -1; |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Retrieves the raw query string, or an empty string if none is present. |
|
212 | - * |
|
213 | - * @return string |
|
214 | - * |
|
215 | - * @see URLInfo::getParams() |
|
216 | - */ |
|
210 | + /** |
|
211 | + * Retrieves the raw query string, or an empty string if none is present. |
|
212 | + * |
|
213 | + * @return string |
|
214 | + * |
|
215 | + * @see URLInfo::getParams() |
|
216 | + */ |
|
217 | 217 | public function getQuery() : string |
218 | 218 | { |
219 | 219 | return $this->getInfoKey('query'); |
@@ -229,20 +229,20 @@ discard block |
||
229 | 229 | return $this->getInfoKey('pass'); |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * Whether the URL contains a port number. |
|
234 | - * @return bool |
|
235 | - */ |
|
232 | + /** |
|
233 | + * Whether the URL contains a port number. |
|
234 | + * @return bool |
|
235 | + */ |
|
236 | 236 | public function hasPort() : bool |
237 | 237 | { |
238 | 238 | return $this->getPort() !== -1; |
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Alias for the hasParams() method. |
|
243 | - * @return bool |
|
244 | - * @see URLInfo::hasParams() |
|
245 | - */ |
|
241 | + /** |
|
242 | + * Alias for the hasParams() method. |
|
243 | + * @return bool |
|
244 | + * @see URLInfo::hasParams() |
|
245 | + */ |
|
246 | 246 | public function hasQuery() : bool |
247 | 247 | { |
248 | 248 | return $this->hasParams(); |
@@ -300,25 +300,25 @@ discard block |
||
300 | 300 | return $this->normalizer->normalize(); |
301 | 301 | } |
302 | 302 | |
303 | - /** |
|
304 | - * Creates a hash of the URL, which can be used for comparisons. |
|
305 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
306 | - * the same links with a different parameter order will have the |
|
307 | - * same hash. |
|
308 | - * |
|
309 | - * @return string |
|
310 | - */ |
|
303 | + /** |
|
304 | + * Creates a hash of the URL, which can be used for comparisons. |
|
305 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
306 | + * the same links with a different parameter order will have the |
|
307 | + * same hash. |
|
308 | + * |
|
309 | + * @return string |
|
310 | + */ |
|
311 | 311 | public function getHash() |
312 | 312 | { |
313 | 313 | return \AppUtils\ConvertHelper::string2shortHash($this->getNormalized()); |
314 | 314 | } |
315 | 315 | |
316 | - /** |
|
317 | - * Highlights the URL using HTML tags with specific highlighting |
|
318 | - * class names. |
|
319 | - * |
|
320 | - * @return string Will return an empty string if the URL is not valid. |
|
321 | - */ |
|
316 | + /** |
|
317 | + * Highlights the URL using HTML tags with specific highlighting |
|
318 | + * class names. |
|
319 | + * |
|
320 | + * @return string Will return an empty string if the URL is not valid. |
|
321 | + */ |
|
322 | 322 | public function getHighlighted() : string |
323 | 323 | { |
324 | 324 | if(!$this->isValid()) { |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | return count($params); |
353 | 353 | } |
354 | 354 | |
355 | - /** |
|
356 | - * Retrieves all parameters specified in the url, |
|
357 | - * if any, as an associative array. |
|
358 | - * |
|
359 | - * NOTE: Ignores parameters that have been added |
|
360 | - * to the excluded parameters list. |
|
361 | - * |
|
362 | - * @return array |
|
363 | - */ |
|
355 | + /** |
|
356 | + * Retrieves all parameters specified in the url, |
|
357 | + * if any, as an associative array. |
|
358 | + * |
|
359 | + * NOTE: Ignores parameters that have been added |
|
360 | + * to the excluded parameters list. |
|
361 | + * |
|
362 | + * @return array |
|
363 | + */ |
|
364 | 364 | public function getParams() : array |
365 | 365 | { |
366 | 366 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -378,22 +378,22 @@ discard block |
||
378 | 378 | return $keep; |
379 | 379 | } |
380 | 380 | |
381 | - /** |
|
382 | - * Retrieves the names of all parameters present in the URL, if any. |
|
383 | - * @return string[] |
|
384 | - */ |
|
381 | + /** |
|
382 | + * Retrieves the names of all parameters present in the URL, if any. |
|
383 | + * @return string[] |
|
384 | + */ |
|
385 | 385 | public function getParamNames() : array |
386 | 386 | { |
387 | 387 | $params = $this->getParams(); |
388 | 388 | return array_keys($params); |
389 | 389 | } |
390 | 390 | |
391 | - /** |
|
392 | - * Retrieves a specific parameter value from the URL. |
|
393 | - * |
|
394 | - * @param string $name |
|
395 | - * @return string The parameter value, or an empty string if it does not exist. |
|
396 | - */ |
|
391 | + /** |
|
392 | + * Retrieves a specific parameter value from the URL. |
|
393 | + * |
|
394 | + * @param string $name |
|
395 | + * @return string The parameter value, or an empty string if it does not exist. |
|
396 | + */ |
|
397 | 397 | public function getParam(string $name) : string |
398 | 398 | { |
399 | 399 | if(isset($this->info['params'][$name])) { |
@@ -403,16 +403,16 @@ discard block |
||
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | - /** |
|
407 | - * Excludes an URL parameter entirely if present: |
|
408 | - * the parser will act as if the parameter was not |
|
409 | - * even present in the source URL, effectively |
|
410 | - * stripping it. |
|
411 | - * |
|
412 | - * @param string $name |
|
413 | - * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
414 | - * @return URLInfo |
|
415 | - */ |
|
406 | + /** |
|
407 | + * Excludes an URL parameter entirely if present: |
|
408 | + * the parser will act as if the parameter was not |
|
409 | + * even present in the source URL, effectively |
|
410 | + * stripping it. |
|
411 | + * |
|
412 | + * @param string $name |
|
413 | + * @param string $reason A human readable explanation why this is excluded - used when highlighting links. |
|
414 | + * @return URLInfo |
|
415 | + */ |
|
416 | 416 | public function excludeParam(string $name, string $reason) : URLInfo |
417 | 417 | { |
418 | 418 | if(!isset($this->excludedParams[$name])) |
@@ -465,25 +465,25 @@ discard block |
||
465 | 465 | return self::$typeLabels[$this->getType()]; |
466 | 466 | } |
467 | 467 | |
468 | - /** |
|
469 | - * Whether excluded parameters should be highlighted in |
|
470 | - * a different color in the URL when using the |
|
471 | - * {@link URLInfo::getHighlighted()} method. |
|
472 | - * |
|
473 | - * @param bool $highlight |
|
474 | - * @return URLInfo |
|
475 | - */ |
|
468 | + /** |
|
469 | + * Whether excluded parameters should be highlighted in |
|
470 | + * a different color in the URL when using the |
|
471 | + * {@link URLInfo::getHighlighted()} method. |
|
472 | + * |
|
473 | + * @param bool $highlight |
|
474 | + * @return URLInfo |
|
475 | + */ |
|
476 | 476 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
477 | 477 | { |
478 | 478 | $this->highlightExcluded = $highlight; |
479 | 479 | return $this; |
480 | 480 | } |
481 | 481 | |
482 | - /** |
|
483 | - * Returns an array with all relevant URL information. |
|
484 | - * |
|
485 | - * @return array |
|
486 | - */ |
|
482 | + /** |
|
483 | + * Returns an array with all relevant URL information. |
|
484 | + * |
|
485 | + * @return array |
|
486 | + */ |
|
487 | 487 | public function toArray() : array |
488 | 488 | { |
489 | 489 | return array( |
@@ -527,24 +527,24 @@ discard block |
||
527 | 527 | return $this; |
528 | 528 | } |
529 | 529 | |
530 | - /** |
|
531 | - * Whether the parameter exclusion mode is enabled: |
|
532 | - * In this case, if any parameters have been added to the |
|
533 | - * exclusion list, all relevant methods will exclude these. |
|
534 | - * |
|
535 | - * @return bool |
|
536 | - */ |
|
530 | + /** |
|
531 | + * Whether the parameter exclusion mode is enabled: |
|
532 | + * In this case, if any parameters have been added to the |
|
533 | + * exclusion list, all relevant methods will exclude these. |
|
534 | + * |
|
535 | + * @return bool |
|
536 | + */ |
|
537 | 537 | public function isParamExclusionEnabled() : bool |
538 | 538 | { |
539 | 539 | return $this->paramExclusion; |
540 | 540 | } |
541 | 541 | |
542 | - /** |
|
543 | - * Checks whether the link contains any parameters that |
|
544 | - * are on the list of excluded parameters. |
|
545 | - * |
|
546 | - * @return bool |
|
547 | - */ |
|
542 | + /** |
|
543 | + * Checks whether the link contains any parameters that |
|
544 | + * are on the list of excluded parameters. |
|
545 | + * |
|
546 | + * @return bool |
|
547 | + */ |
|
548 | 548 | public function containsExcludedParams() : bool |
549 | 549 | { |
550 | 550 | if(empty($this->excludedParams)) { |
@@ -612,16 +612,16 @@ discard block |
||
612 | 612 | return $this->highlightExcluded; |
613 | 613 | } |
614 | 614 | |
615 | - /** |
|
616 | - * Checks if the URL exists, i.e. can be connected to. Will return |
|
617 | - * true if the returned HTTP status code is `200` or `302`. |
|
618 | - * |
|
619 | - * NOTE: If the target URL requires HTTP authentication, the username |
|
620 | - * and password should be integrated into the URL. |
|
621 | - * |
|
622 | - * @return bool |
|
623 | - * @throws BaseException |
|
624 | - */ |
|
615 | + /** |
|
616 | + * Checks if the URL exists, i.e. can be connected to. Will return |
|
617 | + * true if the returned HTTP status code is `200` or `302`. |
|
618 | + * |
|
619 | + * NOTE: If the target URL requires HTTP authentication, the username |
|
620 | + * and password should be integrated into the URL. |
|
621 | + * |
|
622 | + * @return bool |
|
623 | + * @throws BaseException |
|
624 | + */ |
|
625 | 625 | public function tryConnect() : bool |
626 | 626 | { |
627 | 627 | requireCURL(); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | $port = $this->getInfoKey('port'); |
202 | 202 | |
203 | - if(!empty($port)) { |
|
203 | + if (!empty($port)) { |
|
204 | 204 | return (int)$port; |
205 | 205 | } |
206 | 206 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | protected function getInfoKey(string $name) : string |
282 | 282 | { |
283 | - if(isset($this->info[$name])) { |
|
283 | + if (isset($this->info[$name])) { |
|
284 | 284 | return (string)$this->info[$name]; |
285 | 285 | } |
286 | 286 | |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | |
290 | 290 | public function getNormalized() : string |
291 | 291 | { |
292 | - if(!$this->isValid()) { |
|
292 | + if (!$this->isValid()) { |
|
293 | 293 | return ''; |
294 | 294 | } |
295 | 295 | |
296 | - if(!isset($this->normalizer)) { |
|
296 | + if (!isset($this->normalizer)) { |
|
297 | 297 | $this->normalizer = new URLInfo_Normalizer($this); |
298 | 298 | } |
299 | 299 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function getHighlighted() : string |
323 | 323 | { |
324 | - if(!$this->isValid()) { |
|
324 | + if (!$this->isValid()) { |
|
325 | 325 | return ''; |
326 | 326 | } |
327 | 327 | |
@@ -363,14 +363,14 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function getParams() : array |
365 | 365 | { |
366 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
366 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
367 | 367 | return $this->info['params']; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $keep = array(); |
371 | - foreach($this->info['params'] as $name => $value) |
|
371 | + foreach ($this->info['params'] as $name => $value) |
|
372 | 372 | { |
373 | - if(!isset($this->excludedParams[$name])) { |
|
373 | + if (!isset($this->excludedParams[$name])) { |
|
374 | 374 | $keep[$name] = $value; |
375 | 375 | } |
376 | 376 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | */ |
397 | 397 | public function getParam(string $name) : string |
398 | 398 | { |
399 | - if(isset($this->info['params'][$name])) { |
|
399 | + if (isset($this->info['params'][$name])) { |
|
400 | 400 | return $this->info['params'][$name]; |
401 | 401 | } |
402 | 402 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | */ |
416 | 416 | public function excludeParam(string $name, string $reason) : URLInfo |
417 | 417 | { |
418 | - if(!isset($this->excludedParams[$name])) |
|
418 | + if (!isset($this->excludedParams[$name])) |
|
419 | 419 | { |
420 | 420 | $this->excludedParams[$name] = $reason; |
421 | 421 | $this->setParamExclusion(); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | |
442 | 442 | public function getTypeLabel() : string |
443 | 443 | { |
444 | - if(!isset(self::$typeLabels)) |
|
444 | + if (!isset(self::$typeLabels)) |
|
445 | 445 | { |
446 | 446 | self::$typeLabels = array( |
447 | 447 | self::TYPE_EMAIL => t('Email'), |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | $type = $this->getType(); |
455 | 455 | |
456 | - if(!isset(self::$typeLabels[$type])) |
|
456 | + if (!isset(self::$typeLabels[$type])) |
|
457 | 457 | { |
458 | 458 | throw new BaseException( |
459 | 459 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param bool $highlight |
474 | 474 | * @return URLInfo |
475 | 475 | */ |
476 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
476 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
477 | 477 | { |
478 | 478 | $this->highlightExcluded = $highlight; |
479 | 479 | return $this; |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @see URLInfo::isParamExclusionEnabled() |
522 | 522 | * @see URLInfo::setHighlightExcluded() |
523 | 523 | */ |
524 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
524 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
525 | 525 | { |
526 | 526 | $this->paramExclusion = $enabled; |
527 | 527 | return $this; |
@@ -547,13 +547,13 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public function containsExcludedParams() : bool |
549 | 549 | { |
550 | - if(empty($this->excludedParams)) { |
|
550 | + if (empty($this->excludedParams)) { |
|
551 | 551 | return false; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $names = array_keys($this->info['params']); |
555 | - foreach($names as $name) { |
|
556 | - if(isset($this->excludedParams[$name])) { |
|
555 | + foreach ($names as $name) { |
|
556 | + if (isset($this->excludedParams[$name])) { |
|
557 | 557 | return true; |
558 | 558 | } |
559 | 559 | } |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | public function offsetSet($offset, $value) |
571 | 571 | { |
572 | - if(in_array($offset, $this->infoKeys)) { |
|
572 | + if (in_array($offset, $this->infoKeys)) { |
|
573 | 573 | $this->info[$offset] = $value; |
574 | 574 | } |
575 | 575 | } |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | |
587 | 587 | public function offsetGet($offset) |
588 | 588 | { |
589 | - if($offset === 'port') { |
|
589 | + if ($offset === 'port') { |
|
590 | 590 | return $this->getPort(); |
591 | 591 | } |
592 | 592 | |
593 | - if(in_array($offset, $this->infoKeys)) { |
|
593 | + if (in_array($offset, $this->infoKeys)) { |
|
594 | 594 | return $this->getInfoKey($offset); |
595 | 595 | } |
596 | 596 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | requireCURL(); |
628 | 628 | |
629 | 629 | $ch = curl_init(); |
630 | - if($ch === false) |
|
630 | + if ($ch === false) |
|
631 | 631 | { |
632 | 632 | throw new BaseException( |
633 | 633 | 'Could not initialize a new cURL instance.', |