@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | private static bool $simulation = false; |
35 | 35 | private DOMDocument $dom; |
36 | 36 | |
37 | - /** |
|
38 | - * Creates a new XMLHelper instance. |
|
39 | - * |
|
40 | - * @return XMLHelper |
|
41 | - */ |
|
37 | + /** |
|
38 | + * Creates a new XMLHelper instance. |
|
39 | + * |
|
40 | + * @return XMLHelper |
|
41 | + */ |
|
42 | 42 | public static function create() : XMLHelper |
43 | 43 | { |
44 | 44 | $dom = new DOMDocument('1.0', 'UTF-8'); |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | return XMLHelper_Converter::fromString($xmlString); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Creates a converter from a SimpleXMLElement instance. |
|
73 | - * @param SimpleXMLElement $element |
|
74 | - * @return XMLHelper_Converter |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Creates a converter from a SimpleXMLElement instance. |
|
73 | + * @param SimpleXMLElement $element |
|
74 | + * @return XMLHelper_Converter |
|
75 | + */ |
|
76 | 76 | public static function convertElement(SimpleXMLElement $element) : XMLHelper_Converter |
77 | 77 | { |
78 | 78 | return XMLHelper_Converter::fromElement($element); |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Creates a converter from a DOMElement instance. |
|
83 | - * @param DOMElement $element |
|
84 | - * @return XMLHelper_Converter |
|
85 | - */ |
|
81 | + /** |
|
82 | + * Creates a converter from a DOMElement instance. |
|
83 | + * @param DOMElement $element |
|
84 | + * @return XMLHelper_Converter |
|
85 | + */ |
|
86 | 86 | public static function convertDOMElement(DOMElement $element) : XMLHelper_Converter |
87 | 87 | { |
88 | 88 | return XMLHelper_Converter::fromDOMElement($element); |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Creates a new helper using an existing DOMDocument object. |
|
93 | - * @param DOMDocument $dom |
|
94 | - */ |
|
91 | + /** |
|
92 | + * Creates a new helper using an existing DOMDocument object. |
|
93 | + * @param DOMDocument $dom |
|
94 | + */ |
|
95 | 95 | public function __construct(DOMDocument $dom) |
96 | 96 | { |
97 | 97 | $this->dom = $dom; |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * @return DOMDocument |
|
102 | - */ |
|
100 | + /** |
|
101 | + * @return DOMDocument |
|
102 | + */ |
|
103 | 103 | public function getDOM() : DOMDocument |
104 | 104 | { |
105 | 105 | return $this->dom; |
@@ -299,12 +299,12 @@ discard block |
||
299 | 299 | return $root; |
300 | 300 | } |
301 | 301 | |
302 | - /** |
|
303 | - * Escaped the string for use in XML. |
|
304 | - * |
|
305 | - * @param string $string |
|
306 | - * @return string |
|
307 | - */ |
|
302 | + /** |
|
303 | + * Escaped the string for use in XML. |
|
304 | + * |
|
305 | + * @param string $string |
|
306 | + * @return string |
|
307 | + */ |
|
308 | 308 | public function escape(string $string) : string |
309 | 309 | { |
310 | 310 | return preg_replace('#<p>(.*)</p>#isUm', '$1', $string); |
@@ -331,18 +331,18 @@ discard block |
||
331 | 331 | ); |
332 | 332 | } |
333 | 333 | |
334 | - /** |
|
335 | - * Sends the specified XML string to the browser with |
|
336 | - * the correct headers to trigger a download of the XML |
|
337 | - * to a local file. |
|
338 | - * |
|
339 | - * NOTE: Ensure calling exit after this is done, and to |
|
340 | - * not send additional content, which would corrupt the |
|
341 | - * download. |
|
342 | - * |
|
343 | - * @param string $xml |
|
344 | - * @param string $filename |
|
345 | - */ |
|
334 | + /** |
|
335 | + * Sends the specified XML string to the browser with |
|
336 | + * the correct headers to trigger a download of the XML |
|
337 | + * to a local file. |
|
338 | + * |
|
339 | + * NOTE: Ensure calling exit after this is done, and to |
|
340 | + * not send additional content, which would corrupt the |
|
341 | + * download. |
|
342 | + * |
|
343 | + * @param string $xml |
|
344 | + * @param string $filename |
|
345 | + */ |
|
346 | 346 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
347 | 347 | { |
348 | 348 | if(!self::$simulation && !headers_sent()) |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | echo $xml; |
354 | 354 | } |
355 | 355 | |
356 | - /** |
|
357 | - * Sends the specified XML string to the browser with |
|
358 | - * the correct headers and terminates the request. |
|
359 | - * |
|
360 | - * @param string $xml |
|
361 | - */ |
|
356 | + /** |
|
357 | + * Sends the specified XML string to the browser with |
|
358 | + * the correct headers and terminates the request. |
|
359 | + * |
|
360 | + * @param string $xml |
|
361 | + */ |
|
362 | 362 | public static function displayXML(string $xml) : void |
363 | 363 | { |
364 | 364 | if(!self::$simulation && !headers_sent()) |
@@ -477,30 +477,30 @@ discard block |
||
477 | 477 | return $this->dom->saveXML(); |
478 | 478 | } |
479 | 479 | |
480 | - /** |
|
481 | - * Creates a new SimpleXML helper instance: this |
|
482 | - * object is useful to work with loading XML strings |
|
483 | - * and files with easy access to any errors that |
|
484 | - * may occurr, since the simplexml functions can be |
|
485 | - * somewhat cryptic. |
|
486 | - * |
|
487 | - * @return XMLHelper_SimpleXML |
|
488 | - */ |
|
480 | + /** |
|
481 | + * Creates a new SimpleXML helper instance: this |
|
482 | + * object is useful to work with loading XML strings |
|
483 | + * and files with easy access to any errors that |
|
484 | + * may occurr, since the simplexml functions can be |
|
485 | + * somewhat cryptic. |
|
486 | + * |
|
487 | + * @return XMLHelper_SimpleXML |
|
488 | + */ |
|
489 | 489 | public static function createSimplexml() : XMLHelper_SimpleXML |
490 | 490 | { |
491 | 491 | return new XMLHelper_SimpleXML(); |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Converts a string to valid XML: can be a text only string |
|
496 | - * or an HTML string. Returns valid XML code. |
|
497 | - * |
|
498 | - * NOTE: The string may contain custom tags, which are |
|
499 | - * preserved. |
|
500 | - * |
|
501 | - * @param string $string |
|
502 | - * @return string |
|
503 | - */ |
|
494 | + /** |
|
495 | + * Converts a string to valid XML: can be a text only string |
|
496 | + * or an HTML string. Returns valid XML code. |
|
497 | + * |
|
498 | + * NOTE: The string may contain custom tags, which are |
|
499 | + * preserved. |
|
500 | + * |
|
501 | + * @param string $string |
|
502 | + * @return string |
|
503 | + */ |
|
504 | 504 | public static function string2xml(string $string) : string |
505 | 505 | { |
506 | 506 | return XMLHelper_HTMLLoader::loadFragment($string)->fragmentToXML(); |
@@ -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 |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | protected RequestHelper_Boundaries $boundaries; |
26 | 26 | protected string $transferEncoding = ''; |
27 | 27 | |
28 | - /** |
|
29 | - * @var array<string,string> |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var array<string,string> |
|
30 | + */ |
|
31 | 31 | protected array $dispositionParams = array(); |
32 | 32 | |
33 | 33 | public function __construct(RequestHelper_Boundaries $boundaries, string $content) |
@@ -41,46 +41,46 @@ discard block |
||
41 | 41 | return strlen($this->content); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Sets the name of the request parameter. |
|
46 | - * |
|
47 | - * @param string $name |
|
48 | - * @return RequestHelper_Boundaries_Boundary |
|
49 | - */ |
|
44 | + /** |
|
45 | + * Sets the name of the request parameter. |
|
46 | + * |
|
47 | + * @param string $name |
|
48 | + * @return RequestHelper_Boundaries_Boundary |
|
49 | + */ |
|
50 | 50 | public function setName(string $name) : RequestHelper_Boundaries_Boundary |
51 | 51 | { |
52 | 52 | return $this->setDispositionParam('name', $name); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Sets the filename to use for the content, if applicable. |
|
57 | - * |
|
58 | - * @param string $fileName |
|
59 | - * @return RequestHelper_Boundaries_Boundary |
|
60 | - */ |
|
55 | + /** |
|
56 | + * Sets the filename to use for the content, if applicable. |
|
57 | + * |
|
58 | + * @param string $fileName |
|
59 | + * @return RequestHelper_Boundaries_Boundary |
|
60 | + */ |
|
61 | 61 | public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary |
62 | 62 | { |
63 | 63 | return $this->setDispositionParam('filename', $fileName); |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Sets the content type to use for the content. |
|
68 | - * |
|
69 | - * @param string $contentType |
|
70 | - * @return RequestHelper_Boundaries_Boundary |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Sets the content type to use for the content. |
|
68 | + * |
|
69 | + * @param string $contentType |
|
70 | + * @return RequestHelper_Boundaries_Boundary |
|
71 | + */ |
|
72 | 72 | public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary |
73 | 73 | { |
74 | 74 | $this->contentType = $contentType; |
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Sets the encoding to specify for the content. |
|
80 | - * |
|
81 | - * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
82 | - * @return RequestHelper_Boundaries_Boundary |
|
83 | - */ |
|
78 | + /** |
|
79 | + * Sets the encoding to specify for the content. |
|
80 | + * |
|
81 | + * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
82 | + * @return RequestHelper_Boundaries_Boundary |
|
83 | + */ |
|
84 | 84 | public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary |
85 | 85 | { |
86 | 86 | $this->contentEncoding = $encoding; |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Renders the mime boundary text. |
|
105 | - * |
|
106 | - * @return string |
|
107 | - */ |
|
103 | + /** |
|
104 | + * Renders the mime boundary text. |
|
105 | + * |
|
106 | + * @return string |
|
107 | + */ |
|
108 | 108 | public function render() : string |
109 | 109 | { |
110 | 110 | $eol = $this->boundaries->getEOL(); |
@@ -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 | } |
@@ -31,21 +31,21 @@ discard block |
||
31 | 31 | protected array $info; |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @param RequestHelper $helper |
|
36 | - * @param array<string,mixed> $info The CURL info array from curl_getinfo(). |
|
37 | - */ |
|
34 | + /** |
|
35 | + * @param RequestHelper $helper |
|
36 | + * @param array<string,mixed> $info The CURL info array from curl_getinfo(). |
|
37 | + */ |
|
38 | 38 | public function __construct(RequestHelper $helper, array $info) |
39 | 39 | { |
40 | 40 | $this->request = $helper; |
41 | 41 | $this->info = $info; |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Retrieves the request instance that initiated the request. |
|
46 | - * |
|
47 | - * @return RequestHelper |
|
48 | - */ |
|
44 | + /** |
|
45 | + * Retrieves the request instance that initiated the request. |
|
46 | + * |
|
47 | + * @return RequestHelper |
|
48 | + */ |
|
49 | 49 | public function getRequest() : RequestHelper |
50 | 50 | { |
51 | 51 | return $this->request; |
@@ -66,79 +66,79 @@ discard block |
||
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Whether an error occurred in the request. |
|
71 | - * @return bool |
|
72 | - */ |
|
69 | + /** |
|
70 | + * Whether an error occurred in the request. |
|
71 | + * @return bool |
|
72 | + */ |
|
73 | 73 | public function isError() : bool |
74 | 74 | { |
75 | 75 | return $this->isError; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Whether the request timed out. |
|
80 | - * @return bool |
|
81 | - */ |
|
78 | + /** |
|
79 | + * Whether the request timed out. |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | 82 | public function isTimeout() : bool |
83 | 83 | { |
84 | 84 | return $this->errorCode === RequestHelper_CURL::OPERATION_TIMEDOUT; |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * Retrieves the native error message, if an error occurred. |
|
89 | - * @return string |
|
90 | - */ |
|
87 | + /** |
|
88 | + * Retrieves the native error message, if an error occurred. |
|
89 | + * @return string |
|
90 | + */ |
|
91 | 91 | public function getErrorMessage() : string |
92 | 92 | { |
93 | 93 | return $this->errorMessage; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Retrieves the native CURL error code, if an error occurred. |
|
98 | - * @return int |
|
99 | - * @see RequestHelper_CURL For a list of error codes. |
|
100 | - */ |
|
96 | + /** |
|
97 | + * Retrieves the native CURL error code, if an error occurred. |
|
98 | + * @return int |
|
99 | + * @see RequestHelper_CURL For a list of error codes. |
|
100 | + */ |
|
101 | 101 | public function getErrorCode() : int |
102 | 102 | { |
103 | 103 | return $this->errorCode; |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * Retrieves the full body of the request. |
|
108 | - * |
|
109 | - * @return string |
|
110 | - */ |
|
106 | + /** |
|
107 | + * Retrieves the full body of the request. |
|
108 | + * |
|
109 | + * @return string |
|
110 | + */ |
|
111 | 111 | public function getRequestBody() : string |
112 | 112 | { |
113 | 113 | return $this->request->getBody(); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Retrieves the body of the response, if any. |
|
118 | - * |
|
119 | - * @return string |
|
120 | - */ |
|
116 | + /** |
|
117 | + * Retrieves the body of the response, if any. |
|
118 | + * |
|
119 | + * @return string |
|
120 | + */ |
|
121 | 121 | public function getResponseBody() : string |
122 | 122 | { |
123 | 123 | return $this->body; |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * The response HTTP code. |
|
128 | - * |
|
129 | - * @return int The code, or 0 if none was sent (on error). |
|
130 | - */ |
|
126 | + /** |
|
127 | + * The response HTTP code. |
|
128 | + * |
|
129 | + * @return int The code, or 0 if none was sent (on error). |
|
130 | + */ |
|
131 | 131 | public function getCode() : int |
132 | 132 | { |
133 | 133 | return (int)$this->getInfoKey('http_code'); |
134 | 134 | } |
135 | 135 | |
136 | - /** |
|
137 | - * Retrieves the actual headers that were sent in the request: |
|
138 | - * one header by entry in the indexed array. |
|
139 | - * |
|
140 | - * @return string[] |
|
141 | - */ |
|
136 | + /** |
|
137 | + * Retrieves the actual headers that were sent in the request: |
|
138 | + * one header by entry in the indexed array. |
|
139 | + * |
|
140 | + * @return string[] |
|
141 | + */ |
|
142 | 142 | public function getHeaders() : array |
143 | 143 | { |
144 | 144 | return ConvertHelper::explodeTrim("\n", $this->getInfoKey('request_header')); |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | |
38 | 38 | public const ERROR_INVALID_SERIALIZED_DATA = 56301; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $string; |
44 | 44 | |
45 | - /** |
|
46 | - * @var mixed |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var mixed |
|
47 | + */ |
|
48 | 48 | protected $value; |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $type; |
54 | 54 | |
55 | 55 | /** |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | return new VariableInfo(null, $serialized); |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Parses a previously serialized data set to restore the |
|
111 | - * variable information from it. |
|
112 | - * |
|
113 | - * @param array<mixed> $serialized |
|
114 | - * @throws BaseException |
|
115 | - * |
|
116 | - * @see VariableInfo::ERROR_INVALID_SERIALIZED_DATA |
|
117 | - */ |
|
109 | + /** |
|
110 | + * Parses a previously serialized data set to restore the |
|
111 | + * variable information from it. |
|
112 | + * |
|
113 | + * @param array<mixed> $serialized |
|
114 | + * @throws BaseException |
|
115 | + * |
|
116 | + * @see VariableInfo::ERROR_INVALID_SERIALIZED_DATA |
|
117 | + */ |
|
118 | 118 | protected function parseSerialized(array $serialized) : void |
119 | 119 | { |
120 | 120 | if(!isset($serialized['string'], $serialized['type'], $serialized['options'])) |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | return $this->value; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * The variable type - this is the same string that |
|
168 | - * is returned by the PHP function `gettype`. |
|
169 | - * |
|
170 | - * @return string |
|
171 | - */ |
|
166 | + /** |
|
167 | + * The variable type - this is the same string that |
|
168 | + * is returned by the PHP function `gettype`. |
|
169 | + * |
|
170 | + * @return string |
|
171 | + */ |
|
172 | 172 | public function getType() : string |
173 | 173 | { |
174 | 174 | return $this->type; |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | ); |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Whether to prepend the variable type before the value, |
|
190 | - * like the var_dump function. Example: <code>string "Some text"</code>. |
|
191 | - * |
|
192 | - * @param bool $enable |
|
193 | - * @return VariableInfo |
|
194 | - */ |
|
188 | + /** |
|
189 | + * Whether to prepend the variable type before the value, |
|
190 | + * like the var_dump function. Example: <code>string "Some text"</code>. |
|
191 | + * |
|
192 | + * @param bool $enable |
|
193 | + * @return VariableInfo |
|
194 | + */ |
|
195 | 195 | public function enableType(bool $enable=true) : VariableInfo |
196 | 196 | { |
197 | 197 | return $this->setOption('prepend-type', $enable); |
@@ -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 | } |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | |
29 | 29 | public const DEF_DEPTH = 512; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array<string,mixed> |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array<string,mixed> |
|
33 | + */ |
|
34 | 34 | private array $options = array( |
35 | 35 | '@attributes' => true, |
36 | 36 | '@text' => true, |
37 | 37 | 'depth' => self::DEF_DEPTH |
38 | 38 | ); |
39 | 39 | |
40 | - /** |
|
41 | - * @var array<mixed>|string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var array<mixed>|string |
|
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; |
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; |
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); |
@@ -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 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | protected SimpleXMLElement $xml; |
51 | 51 | |
52 | - /** |
|
53 | - * @var string|NULL |
|
54 | - */ |
|
52 | + /** |
|
53 | + * @var string|NULL |
|
54 | + */ |
|
55 | 55 | protected ?string $json; |
56 | 56 | |
57 | 57 | protected function __construct(SimpleXMLElement $element) |
@@ -96,34 +96,34 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
101 | - * |
|
102 | - * @param SimpleXMLElement $element |
|
103 | - * @return XMLHelper_Converter |
|
104 | - */ |
|
99 | + /** |
|
100 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
101 | + * |
|
102 | + * @param SimpleXMLElement $element |
|
103 | + * @return XMLHelper_Converter |
|
104 | + */ |
|
105 | 105 | public static function fromElement(SimpleXMLElement $element) : XMLHelper_Converter |
106 | 106 | { |
107 | 107 | return new XMLHelper_Converter($element); |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
112 | - * |
|
113 | - * @param DOMElement $element |
|
114 | - * @return XMLHelper_Converter |
|
115 | - */ |
|
110 | + /** |
|
111 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
112 | + * |
|
113 | + * @param DOMElement $element |
|
114 | + * @return XMLHelper_Converter |
|
115 | + */ |
|
116 | 116 | public static function fromDOMElement(DOMElement $element) : XMLHelper_Converter |
117 | 117 | { |
118 | 118 | return new XMLHelper_Converter(simplexml_import_dom($element)); |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Converts the XML to JSON. |
|
123 | - * |
|
124 | - * @return string |
|
125 | - * @throws XMLHelper_Exception|JsonException |
|
126 | - */ |
|
121 | + /** |
|
122 | + * Converts the XML to JSON. |
|
123 | + * |
|
124 | + * @return string |
|
125 | + * @throws XMLHelper_Exception|JsonException |
|
126 | + */ |
|
127 | 127 | public function toJSON() : string |
128 | 128 | { |
129 | 129 | if (isset($this->json)) |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - /** |
|
160 | - * Converts the XML to an associative array. |
|
161 | - * @return array<mixed> |
|
162 | - * @throws XMLHelper_Exception |
|
163 | - * @throws JsonException |
|
164 | - */ |
|
159 | + /** |
|
160 | + * Converts the XML to an associative array. |
|
161 | + * @return array<mixed> |
|
162 | + * @throws XMLHelper_Exception |
|
163 | + * @throws JsonException |
|
164 | + */ |
|
165 | 165 | public function toArray() : array |
166 | 166 | { |
167 | 167 | $json = $this->toJSON(); |
@@ -84,8 +84,7 @@ discard block |
||
84 | 84 | try |
85 | 85 | { |
86 | 86 | return self::fromElement(new SimpleXMLElement($xmlString)); |
87 | - } |
|
88 | - catch (Exception $e) |
|
87 | + } catch (Exception $e) |
|
89 | 88 | { |
90 | 89 | throw new XMLHelper_Exception( |
91 | 90 | 'Cannot create new element from string.', |
@@ -140,8 +139,7 @@ discard block |
||
140 | 139 | unset($this->xml); |
141 | 140 | |
142 | 141 | return $this->json; |
143 | - } |
|
144 | - catch (Exception $e) |
|
142 | + } catch (Exception $e) |
|
145 | 143 | { |
146 | 144 | throw new XMLHelper_Exception( |
147 | 145 | 'Could not convert the XML source to JSON', |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | { |
26 | 26 | public const SERIALIZE_SEPARATOR = '__SERIALIZE_SEP__'; |
27 | 27 | |
28 | - /** |
|
29 | - * @var XMLHelper_DOMErrors_Error[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var XMLHelper_DOMErrors_Error[] |
|
30 | + */ |
|
31 | 31 | private array $errors = array(); |
32 | 32 | |
33 | - /** |
|
34 | - * @param LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @param LibXMLError[]|XMLHelper_DOMErrors_Error[] $libxmlErrors |
|
35 | + */ |
|
36 | 36 | public function __construct(array $libxmlErrors) |
37 | 37 | { |
38 | 38 | foreach($libxmlErrors as $error) |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | return $this->errors; |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
65 | - * Retrieves all warnings, if any. |
|
66 | - * |
|
67 | - * @return XMLHelper_DOMErrors_Error[] |
|
68 | - */ |
|
64 | + /** |
|
65 | + * Retrieves all warnings, if any. |
|
66 | + * |
|
67 | + * @return XMLHelper_DOMErrors_Error[] |
|
68 | + */ |
|
69 | 69 | public function getWarnings() : array |
70 | 70 | { |
71 | 71 | return $this->getByLevel(LIBXML_ERR_WARNING); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Retrieves all errors by the specified libxml error level. |
|
126 | - * |
|
127 | - * @param int $level |
|
128 | - * @return XMLHelper_DOMErrors_Error[] |
|
129 | - */ |
|
124 | + /** |
|
125 | + * Retrieves all errors by the specified libxml error level. |
|
126 | + * |
|
127 | + * @param int $level |
|
128 | + * @return XMLHelper_DOMErrors_Error[] |
|
129 | + */ |
|
130 | 130 | public function getByLevel(int $level) : array |
131 | 131 | { |
132 | 132 | $result = array(); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | return $result; |
143 | 143 | } |
144 | 144 | |
145 | - /** |
|
146 | - * Retrieves all errors by the specified libxml error code. |
|
147 | - * |
|
148 | - * @param int $code |
|
149 | - * @return XMLHelper_DOMErrors_Error[] |
|
150 | - */ |
|
145 | + /** |
|
146 | + * Retrieves all errors by the specified libxml error code. |
|
147 | + * |
|
148 | + * @param int $code |
|
149 | + * @return XMLHelper_DOMErrors_Error[] |
|
150 | + */ |
|
151 | 151 | public function getByCode(int $code) : array |
152 | 152 | { |
153 | 153 | $result = array(); |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | return $result; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
167 | - * Checks whether there are errors matching the libxml error level. |
|
168 | - * |
|
169 | - * @param int $level |
|
170 | - * @return bool |
|
171 | - */ |
|
166 | + /** |
|
167 | + * Checks whether there are errors matching the libxml error level. |
|
168 | + * |
|
169 | + * @param int $level |
|
170 | + * @return bool |
|
171 | + */ |
|
172 | 172 | public function hasErrorsByLevel(int $level) : bool |
173 | 173 | { |
174 | 174 | foreach($this->errors as $error) |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | - /** |
|
186 | - * Checks whether there are any errors matching the libxml error code. |
|
187 | - * |
|
188 | - * @param int $code |
|
189 | - * @return bool |
|
190 | - */ |
|
185 | + /** |
|
186 | + * Checks whether there are any errors matching the libxml error code. |
|
187 | + * |
|
188 | + * @param int $code |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | 191 | public function hasErrorsByCode(int $code) : bool |
192 | 192 | { |
193 | 193 | foreach($this->errors as $error) |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | return $result; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * Serializes the error collection, so it can be stored and |
|
221 | - * restored as needed, using the `fromSerialized()` method. |
|
222 | - * |
|
223 | - * @return string |
|
224 | - * @see XMLHelper_DOMErrors::fromSerialized() |
|
225 | - */ |
|
219 | + /** |
|
220 | + * Serializes the error collection, so it can be stored and |
|
221 | + * restored as needed, using the `fromSerialized()` method. |
|
222 | + * |
|
223 | + * @return string |
|
224 | + * @see XMLHelper_DOMErrors::fromSerialized() |
|
225 | + */ |
|
226 | 226 | public function serialize() : string |
227 | 227 | { |
228 | 228 | $data = array(); |
@@ -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 | } |
@@ -40,8 +40,7 @@ |
||
40 | 40 | if($error instanceof XMLHelper_DOMErrors_Error) |
41 | 41 | { |
42 | 42 | $this->errors[] = $error; |
43 | - } |
|
44 | - else if($error instanceof LibXMLError) |
|
43 | + } else if($error instanceof LibXMLError) |
|
45 | 44 | { |
46 | 45 | $this->errors[] = new XMLHelper_DOMErrors_Error($error); |
47 | 46 | } |
@@ -27,9 +27,9 @@ |
||
27 | 27 | public const ERROR_CANNOT_UNSERIALIZE_ERROR_DATA = 57201; |
28 | 28 | public const ERROR_ERROR_DATA_KEY_MISSING = 57202; |
29 | 29 | |
30 | - /** |
|
31 | - * @var LibXMLError |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var LibXMLError |
|
32 | + */ |
|
33 | 33 | private LibXMLError $error; |
34 | 34 | |
35 | 35 | /** |
@@ -90,9 +90,9 @@ |
||
90 | 90 | */ |
91 | 91 | private static function checkErrorData(array $data) : void |
92 | 92 | { |
93 | - foreach(self::$requiredKeys as $key) |
|
93 | + foreach (self::$requiredKeys as $key) |
|
94 | 94 | { |
95 | - if(!array_key_exists($key, $data)) |
|
95 | + if (!array_key_exists($key, $data)) |
|
96 | 96 | { |
97 | 97 | throw new XMLHelper_Exception( |
98 | 98 | 'Required key missing in error data', |
@@ -58,8 +58,7 @@ |
||
58 | 58 | try |
59 | 59 | { |
60 | 60 | $data = json_decode($serialized, true, 512, JSON_THROW_ON_ERROR); |
61 | - } |
|
62 | - catch (JsonException $e) |
|
61 | + } catch (JsonException $e) |
|
63 | 62 | { |
64 | 63 | throw new XMLHelper_Exception( |
65 | 64 | 'Could not unserialize error data', |
@@ -28,32 +28,32 @@ |
||
28 | 28 | |
29 | 29 | private ?SimpleXMLElement $element = null; |
30 | 30 | |
31 | - /** |
|
32 | - * @var XMLHelper_SimpleXML_Error[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var XMLHelper_SimpleXML_Error[] |
|
33 | + */ |
|
34 | 34 | private array $errors = array(); |
35 | 35 | |
36 | - /** |
|
37 | - * Creates a simplexml instance from an XML string. |
|
38 | - * |
|
39 | - * NOTE: returns false in case of a fatal error. |
|
40 | - * |
|
41 | - * @param string $string |
|
42 | - * @return SimpleXMLElement|NULL |
|
43 | - */ |
|
36 | + /** |
|
37 | + * Creates a simplexml instance from an XML string. |
|
38 | + * |
|
39 | + * NOTE: returns false in case of a fatal error. |
|
40 | + * |
|
41 | + * @param string $string |
|
42 | + * @return SimpleXMLElement|NULL |
|
43 | + */ |
|
44 | 44 | public function loadString(string $string) : ?SimpleXMLElement |
45 | 45 | { |
46 | 46 | return $this->load('string', $string); |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Creates a simplexml instance from an XML file. |
|
51 | - * |
|
52 | - * NOTE: returns false in case of a fatal error. |
|
53 | - * |
|
54 | - * @param string $file |
|
55 | - * @return SimpleXMLElement|NULL |
|
56 | - */ |
|
49 | + /** |
|
50 | + * Creates a simplexml instance from an XML file. |
|
51 | + * |
|
52 | + * NOTE: returns false in case of a fatal error. |
|
53 | + * |
|
54 | + * @param string $file |
|
55 | + * @return SimpleXMLElement|NULL |
|
56 | + */ |
|
57 | 57 | public function loadFile(string $file) : ?SimpleXMLElement |
58 | 58 | { |
59 | 59 | return $this->load('file', $file); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | // error wrappers. |
84 | 84 | $errors = libxml_get_errors(); |
85 | 85 | |
86 | - foreach($errors as $error) |
|
86 | + foreach ($errors as $error) |
|
87 | 87 | { |
88 | 88 | $this->errors[] = new XMLHelper_SimpleXML_Error($this, $error); |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $xml = $function($subject); |
99 | 99 | |
100 | - if($xml instanceof SimpleXMLElement) |
|
100 | + if ($xml instanceof SimpleXMLElement) |
|
101 | 101 | { |
102 | 102 | return $xml; |
103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function getConverter() : XMLHelper_Converter |
109 | 109 | { |
110 | - if($this->element instanceof SimpleXMLElement) |
|
110 | + if ($this->element instanceof SimpleXMLElement) |
|
111 | 111 | { |
112 | 112 | return XMLHelper::convertElement($this->element); |
113 | 113 | } |