@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | protected function _validate() |
32 | 32 | { |
33 | - if(is_numeric($this->value)) { |
|
33 | + if (is_numeric($this->value)) { |
|
34 | 34 | return $this->value * 1; |
35 | 35 | } |
36 | 36 |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | private function filterScheme() : void |
40 | 40 | { |
41 | - if($this->hasScheme()) |
|
41 | + if ($this->hasScheme()) |
|
42 | 42 | { |
43 | 43 | $this->setScheme(strtolower($this->getScheme())); |
44 | 44 | } |
45 | 45 | else |
46 | 46 | { |
47 | 47 | $scheme = URISchemes::detectScheme($this->url); |
48 | - if(!empty($scheme)) { |
|
48 | + if (!empty($scheme)) { |
|
49 | 49 | $this->setScheme(URISchemes::resolveSchemeName($scheme)); |
50 | 50 | } |
51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | private function filterAuth() : void |
55 | 55 | { |
56 | - if(!$this->hasAuth()) { |
|
56 | + if (!$this->hasAuth()) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | private function filterHost() : void |
67 | 67 | { |
68 | - if(!$this->hasHost()) |
|
68 | + if (!$this->hasHost()) |
|
69 | 69 | { |
70 | 70 | return; |
71 | 71 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | private function filterPath() : void |
80 | 80 | { |
81 | - if($this->hasPath()) { |
|
81 | + if ($this->hasPath()) { |
|
82 | 82 | $this->setPath(str_replace(' ', '', $this->getPath())); |
83 | 83 | } |
84 | 84 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | { |
88 | 88 | $host = $this->getPath(); |
89 | 89 | |
90 | - if(empty($host) || !URLHosts::isHostKnown($host)) |
|
90 | + if (empty($host) || !URLHosts::isHostKnown($host)) |
|
91 | 91 | { |
92 | 92 | return; |
93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $this->setHost($host); |
96 | 96 | $this->removePath(); |
97 | 97 | |
98 | - if(!$this->hasScheme()) { |
|
98 | + if (!$this->hasScheme()) { |
|
99 | 99 | $this->setSchemeHTTPS(); |
100 | 100 | } |
101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->info['params'] = array(); |
106 | 106 | |
107 | 107 | $query = $this->getQuery(); |
108 | - if(empty($query)) { |
|
108 | + if (empty($query)) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | public static function addHost(string $host) : void |
19 | 19 | { |
20 | - if(!self::isHostKnown($host)) { |
|
20 | + if (!self::isHostKnown($host)) { |
|
21 | 21 | self::$knownHosts[] = strtolower($host); |
22 | 22 | } |
23 | 23 | } |
@@ -22,13 +22,13 @@ |
||
22 | 22 | { |
23 | 23 | public function detect() : bool |
24 | 24 | { |
25 | - if($this->getScheme() === 'mailto') { |
|
25 | + if ($this->getScheme() === 'mailto') { |
|
26 | 26 | $this->setHostFromEmail((string)$this->getPath()); |
27 | 27 | $this->setTypeEmail(); |
28 | 28 | return true; |
29 | 29 | } |
30 | 30 | |
31 | - if($this->hasPath() && preg_match(RegexHelper::REGEX_EMAIL, $this->getPath())) |
|
31 | + if ($this->hasPath() && preg_match(RegexHelper::REGEX_EMAIL, $this->getPath())) |
|
32 | 32 | { |
33 | 33 | $this->setHostFromEmail($this->getPath()); |
34 | 34 | $this->setSchemeMailto(); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | public function removeTag(DOMElement $tag) : void |
162 | 162 | { |
163 | - if(isset($tag->parentNode)) |
|
163 | + if (isset($tag->parentNode)) |
|
164 | 164 | { |
165 | 165 | $tag->parentNode->removeChild($tag); |
166 | 166 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | if (!empty($text)) { |
250 | 250 | $fragment = $this->dom->createDocumentFragment(); |
251 | - if(!@$fragment->appendXML($text)) { |
|
251 | + if (!@$fragment->appendXML($text)) { |
|
252 | 252 | throw new XMLHelper_Exception( |
253 | 253 | 'Cannot append XML fragment', |
254 | 254 | sprintf( |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return DOMNode |
293 | 293 | * @throws DOMException |
294 | 294 | */ |
295 | - public function createRoot(string $name, array $attributes=array()) : DOMNode |
|
295 | + public function createRoot(string $name, array $attributes = array()) : DOMNode |
|
296 | 296 | { |
297 | 297 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
298 | 298 | $this->addAttributes($root, $attributes); |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
347 | 347 | { |
348 | - if(!self::$simulation && !headers_sent()) |
|
348 | + if (!self::$simulation && !headers_sent()) |
|
349 | 349 | { |
350 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
350 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | echo $xml; |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function displayXML(string $xml) : void |
363 | 363 | { |
364 | - if(!self::$simulation && !headers_sent()) |
|
364 | + if (!self::$simulation && !headers_sent()) |
|
365 | 365 | { |
366 | 366 | header('Content-Type:text/xml; charset=utf-8'); |
367 | 367 | } |
368 | 368 | |
369 | - if(self::$simulation) |
|
369 | + if (self::$simulation) |
|
370 | 370 | { |
371 | 371 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
372 | 372 | } |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @throws DOMException |
386 | 386 | * @see buildErrorXML() |
387 | 387 | */ |
388 | - public static function displayErrorXML($code, string $message, string $title, array $customInfo=array()) : void |
|
388 | + public static function displayErrorXML($code, string $message, string $title, array $customInfo = array()) : void |
|
389 | 389 | { |
390 | - if(!self::$simulation && !headers_sent()) { |
|
391 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
390 | + if (!self::$simulation && !headers_sent()) { |
|
391 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
395 | 395 | } |
396 | 396 | |
397 | - public static function setSimulation(bool $simulate=true) : void |
|
397 | + public static function setSimulation(bool $simulate = true) : void |
|
398 | 398 | { |
399 | 399 | self::$simulation = $simulate; |
400 | 400 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @return string |
446 | 446 | * @throws DOMException |
447 | 447 | */ |
448 | - public static function buildErrorXML($code, string $message, string $title, array $customInfo=array()) : string |
|
448 | + public static function buildErrorXML($code, string $message, string $title, array $customInfo = array()) : string |
|
449 | 449 | { |
450 | 450 | $xml = new DOMDocument('1.0', 'UTF-8'); |
451 | 451 | $xml->formatOutput = true; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | $helper->addTextTag($root, 'title', $title); |
460 | 460 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
461 | 461 | |
462 | - foreach($customInfo as $name => $value) { |
|
462 | + foreach ($customInfo as $name => $value) { |
|
463 | 463 | $helper->addTextTag($root, $name, $value); |
464 | 464 | } |
465 | 465 |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | $lines[] = '--'.$this->boundaries->getMimeBoundary(); |
114 | 114 | $lines[] = $this->renderContentDisposition(); |
115 | 115 | |
116 | - if(!empty($this->contentType)) |
|
116 | + if (!empty($this->contentType)) |
|
117 | 117 | { |
118 | 118 | $lines[] = $this->renderContentType(); |
119 | 119 | } |
120 | 120 | |
121 | - if(!empty($this->transferEncoding)) |
|
121 | + if (!empty($this->transferEncoding)) |
|
122 | 122 | { |
123 | 123 | $lines[] = $this->renderTransferEncoding(); |
124 | 124 | } |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $result = 'Content-Disposition: form-data'; |
135 | 135 | |
136 | - foreach($this->dispositionParams as $name => $value) |
|
136 | + foreach ($this->dispositionParams as $name => $value) |
|
137 | 137 | { |
138 | - $result .= '; '.$name.'="' . $value . '"'; |
|
138 | + $result .= '; '.$name.'="'.$value.'"'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $result; |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | |
144 | 144 | protected function renderContentType() : string |
145 | 145 | { |
146 | - $result = 'Content-Type: ' . $this->contentType; |
|
146 | + $result = 'Content-Type: '.$this->contentType; |
|
147 | 147 | |
148 | - if(!empty($this->contentEncoding)) |
|
148 | + if (!empty($this->contentEncoding)) |
|
149 | 149 | { |
150 | - $result .= '; charset="' . $this->contentEncoding.'"'; |
|
150 | + $result .= '; charset="'.$this->contentEncoding.'"'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return $result; |
@@ -155,6 +155,6 @@ discard block |
||
155 | 155 | |
156 | 156 | protected function renderTransferEncoding() : string |
157 | 157 | { |
158 | - return 'Content-Transfer-Encoding: ' . $this->transferEncoding; |
|
158 | + return 'Content-Transfer-Encoding: '.$this->transferEncoding; |
|
159 | 159 | } |
160 | 160 | } |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @param array<mixed>|null $serialized |
68 | 68 | * @throws BaseException |
69 | 69 | */ |
70 | - public function __construct($value, ?array $serialized=null) |
|
70 | + public function __construct($value, ?array $serialized = null) |
|
71 | 71 | { |
72 | - if(is_array($serialized)) |
|
72 | + if (is_array($serialized)) |
|
73 | 73 | { |
74 | 74 | $this->parseSerialized($serialized); |
75 | 75 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function parseSerialized(array $serialized) : void |
119 | 119 | { |
120 | - if(!isset($serialized['string'], $serialized['type'], $serialized['options'])) |
|
120 | + if (!isset($serialized['string'], $serialized['type'], $serialized['options'])) |
|
121 | 121 | { |
122 | 122 | throw new BaseException( |
123 | 123 | 'Invalid variable info serialized data.', |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | |
144 | 144 | // Gettype will return a string like "Resource(closed)" when |
145 | 145 | // working with a resource that has already been closed. |
146 | - if(stripos($this->type, 'resource') !== false) |
|
146 | + if (stripos($this->type, 'resource') !== false) |
|
147 | 147 | { |
148 | 148 | $this->type = self::TYPE_RESOURCE; |
149 | 149 | } |
150 | 150 | |
151 | - if(is_callable($value) && in_array($this->type, $this->callableTypes)) { |
|
151 | + if (is_callable($value) && in_array($this->type, $this->callableTypes)) { |
|
152 | 152 | $this->type = self::TYPE_CALLABLE; |
153 | 153 | } |
154 | 154 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param bool $enable |
193 | 193 | * @return VariableInfo |
194 | 194 | */ |
195 | - public function enableType(bool $enable=true) : VariableInfo |
|
195 | + public function enableType(bool $enable = true) : VariableInfo |
|
196 | 196 | { |
197 | 197 | return $this->setOption('prepend-type', $enable); |
198 | 198 | } |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | { |
202 | 202 | $converted = $this->string; |
203 | 203 | |
204 | - if($this->getOption('prepend-type') === true && !$this->isNull()) |
|
204 | + if ($this->getOption('prepend-type') === true && !$this->isNull()) |
|
205 | 205 | { |
206 | - if($this->isString()) |
|
206 | + if ($this->isString()) |
|
207 | 207 | { |
208 | 208 | $converted = '"'.$converted.'"'; |
209 | 209 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $this->traverseChildren(); |
97 | 97 | $this->encodeTextElements(); |
98 | 98 | |
99 | - if(is_array($this->result) && !empty($this->result)) |
|
99 | + if (is_array($this->result) && !empty($this->result)) |
|
100 | 100 | { |
101 | 101 | return $this->result; |
102 | 102 | } |
@@ -107,20 +107,20 @@ discard block |
||
107 | 107 | |
108 | 108 | protected function detectAttributes() : void |
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($attributes === null) |
|
116 | + if ($attributes === null) |
|
117 | 117 | { |
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | $values = array_map('strval', iterator_to_array($attributes)); |
122 | 122 | |
123 | - if(!empty($values)) |
|
123 | + if (!empty($values)) |
|
124 | 124 | { |
125 | 125 | $this->result['@attributes'] = $values; |
126 | 126 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $children = $this->subject; |
132 | 132 | $depth = $this->options['depth'] - 1; |
133 | 133 | |
134 | - if($depth <= 0) |
|
134 | + if ($depth <= 0) |
|
135 | 135 | { |
136 | 136 | $children = []; |
137 | 137 | } |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | |
145 | 145 | $decorator->options = ['depth' => $depth] + $this->options; |
146 | 146 | |
147 | - if(isset($this->result[$name])) |
|
147 | + if (isset($this->result[$name])) |
|
148 | 148 | { |
149 | - if(!is_array($this->result[$name])) |
|
149 | + if (!is_array($this->result[$name])) |
|
150 | 150 | { |
151 | 151 | $this->result[$name] = array($this->result[$name]); |
152 | 152 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | // json encode non-whitespace element simplexml text values. |
166 | 166 | $text = trim((string)$this->subject); |
167 | 167 | |
168 | - if($text !== '') |
|
168 | + if ($text !== '') |
|
169 | 169 | { |
170 | - if($this->options['@text']) |
|
170 | + if ($this->options['@text']) |
|
171 | 171 | { |
172 | 172 | $this->result['@text'] = $text; |
173 | 173 | } |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function __construct(array $libxmlErrors) |
37 | 37 | { |
38 | - foreach($libxmlErrors as $error) |
|
38 | + foreach ($libxmlErrors as $error) |
|
39 | 39 | { |
40 | - if($error instanceof XMLHelper_DOMErrors_Error) |
|
40 | + if ($error instanceof XMLHelper_DOMErrors_Error) |
|
41 | 41 | { |
42 | 42 | $this->errors[] = $error; |
43 | 43 | } |
44 | - else if($error instanceof LibXMLError) |
|
44 | + else if ($error instanceof LibXMLError) |
|
45 | 45 | { |
46 | 46 | $this->errors[] = new XMLHelper_DOMErrors_Error($error); |
47 | 47 | } |
@@ -131,9 +131,9 @@ discard block |
||
131 | 131 | { |
132 | 132 | $result = array(); |
133 | 133 | |
134 | - foreach($this->errors as $error) |
|
134 | + foreach ($this->errors as $error) |
|
135 | 135 | { |
136 | - if($error->isLevel($level)) |
|
136 | + if ($error->isLevel($level)) |
|
137 | 137 | { |
138 | 138 | $result[] = $error; |
139 | 139 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | { |
153 | 153 | $result = array(); |
154 | 154 | |
155 | - foreach($this->errors as $error) |
|
155 | + foreach ($this->errors as $error) |
|
156 | 156 | { |
157 | - if($error->isCode($code)) |
|
157 | + if ($error->isCode($code)) |
|
158 | 158 | { |
159 | 159 | $result[] = $error; |
160 | 160 | } |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function hasErrorsByLevel(int $level) : bool |
173 | 173 | { |
174 | - foreach($this->errors as $error) |
|
174 | + foreach ($this->errors as $error) |
|
175 | 175 | { |
176 | - if($error->isLevel($level)) |
|
176 | + if ($error->isLevel($level)) |
|
177 | 177 | { |
178 | 178 | return true; |
179 | 179 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function hasErrorsByCode(int $code) : bool |
192 | 192 | { |
193 | - foreach($this->errors as $error) |
|
193 | + foreach ($this->errors as $error) |
|
194 | 194 | { |
195 | - if($error->isCode($code)) |
|
195 | + if ($error->isCode($code)) |
|
196 | 196 | { |
197 | 197 | return true; |
198 | 198 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | $result = array(); |
210 | 210 | |
211 | - foreach($this->errors as $error) |
|
211 | + foreach ($this->errors as $error) |
|
212 | 212 | { |
213 | 213 | $result[] = $error->toArray(); |
214 | 214 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | $data = array(); |
229 | 229 | |
230 | - foreach($this->errors as $error) |
|
230 | + foreach ($this->errors as $error) |
|
231 | 231 | { |
232 | 232 | $data[] = $error->serialize(); |
233 | 233 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $parts = explode(self::SERIALIZE_SEPARATOR, $serialized); |
250 | 250 | $list = array(); |
251 | 251 | |
252 | - foreach($parts as $part) |
|
252 | + foreach ($parts as $part) |
|
253 | 253 | { |
254 | 254 | $list[] = XMLHelper_DOMErrors_Error::fromSerialized($part); |
255 | 255 | } |