@@ -32,41 +32,41 @@ discard block |
||
32 | 32 | return new XMLHelper($dom); |
33 | 33 | } |
34 | 34 | |
35 | - /** |
|
36 | - * Creates a converter instance from an XML file. |
|
37 | - * @param string $xmlFile |
|
38 | - * @return \AppUtils\XMLHelper_Converter |
|
39 | - */ |
|
35 | + /** |
|
36 | + * Creates a converter instance from an XML file. |
|
37 | + * @param string $xmlFile |
|
38 | + * @return \AppUtils\XMLHelper_Converter |
|
39 | + */ |
|
40 | 40 | public static function convertFile(string $xmlFile) |
41 | 41 | { |
42 | 42 | return XMLHelper_Converter::fromFile($xmlFile); |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * Creates a converter from an XML string. |
|
47 | - * @param string $xmlString |
|
48 | - * @return \AppUtils\XMLHelper_Converter |
|
49 | - */ |
|
45 | + /** |
|
46 | + * Creates a converter from an XML string. |
|
47 | + * @param string $xmlString |
|
48 | + * @return \AppUtils\XMLHelper_Converter |
|
49 | + */ |
|
50 | 50 | public static function convertString(string $xmlString) |
51 | 51 | { |
52 | 52 | return XMLHelper_Converter::fromString($xmlString); |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Creates a converter from a SimpleXMLElement instance. |
|
57 | - * @param \SimpleXMLElement $element |
|
58 | - * @return \AppUtils\XMLHelper_Converter |
|
59 | - */ |
|
55 | + /** |
|
56 | + * Creates a converter from a SimpleXMLElement instance. |
|
57 | + * @param \SimpleXMLElement $element |
|
58 | + * @return \AppUtils\XMLHelper_Converter |
|
59 | + */ |
|
60 | 60 | public static function convertElement(\SimpleXMLElement $element) |
61 | 61 | { |
62 | 62 | return XMLHelper_Converter::fromElement($element); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Creates a converter from a DOMElement instance. |
|
67 | - * @param \DOMElement $element |
|
68 | - * @return \AppUtils\XMLHelper_Converter |
|
69 | - */ |
|
65 | + /** |
|
66 | + * Creates a converter from a DOMElement instance. |
|
67 | + * @param \DOMElement $element |
|
68 | + * @return \AppUtils\XMLHelper_Converter |
|
69 | + */ |
|
70 | 70 | public static function convertDOMElement(\DOMElement $element) |
71 | 71 | { |
72 | 72 | return XMLHelper_Converter::fromDOMElement($element); |
@@ -435,31 +435,31 @@ discard block |
||
435 | 435 | return $this->dom->saveXML(); |
436 | 436 | } |
437 | 437 | |
438 | - /** |
|
439 | - * Creates a new SimpleXML helper instance: this |
|
440 | - * object is useful to work with loading XML strings |
|
441 | - * and files with easy access to any errors that |
|
442 | - * may occurr, since the simplexml functions can be |
|
443 | - * somewhat cryptic. |
|
444 | - * |
|
445 | - * @return XMLHelper_SimpleXML |
|
446 | - */ |
|
438 | + /** |
|
439 | + * Creates a new SimpleXML helper instance: this |
|
440 | + * object is useful to work with loading XML strings |
|
441 | + * and files with easy access to any errors that |
|
442 | + * may occurr, since the simplexml functions can be |
|
443 | + * somewhat cryptic. |
|
444 | + * |
|
445 | + * @return XMLHelper_SimpleXML |
|
446 | + */ |
|
447 | 447 | public static function createSimplexml() |
448 | 448 | { |
449 | 449 | return new XMLHelper_SimpleXML(); |
450 | 450 | } |
451 | 451 | |
452 | - /** |
|
453 | - * Converts a string to valid XML: can be a text only string |
|
454 | - * or an HTML string. Returns valid XML code. |
|
455 | - * |
|
456 | - * NOTE: The string may contain custom tags, which are |
|
457 | - * preserved. |
|
458 | - * |
|
459 | - * @param string $string |
|
460 | - * @throws XMLHelper_Exception |
|
461 | - * @return string |
|
462 | - */ |
|
452 | + /** |
|
453 | + * Converts a string to valid XML: can be a text only string |
|
454 | + * or an HTML string. Returns valid XML code. |
|
455 | + * |
|
456 | + * NOTE: The string may contain custom tags, which are |
|
457 | + * preserved. |
|
458 | + * |
|
459 | + * @param string $string |
|
460 | + * @throws XMLHelper_Exception |
|
461 | + * @return string |
|
462 | + */ |
|
463 | 463 | public static function string2xml(string $string) : string |
464 | 464 | { |
465 | 465 | return XMLHelper_HTMLLoader::loadFragment($string)->fragmentToXML(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function addAttribute($parent, string $name, $value) |
107 | 107 | { |
108 | - if(!$parent instanceof \DOMNode) { |
|
108 | + if (!$parent instanceof \DOMNode) { |
|
109 | 109 | throw new XMLHelper_Exception( |
110 | 110 | 'The specified parent node is not a node instance.', |
111 | 111 | sprintf('Tried adding attribute [%s].', $name), |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | if (!empty($text)) { |
229 | 229 | $fragment = $this->dom->createDocumentFragment(); |
230 | - if(!@$fragment->appendXML($text)) { |
|
230 | + if (!@$fragment->appendXML($text)) { |
|
231 | 231 | throw new XMLHelper_Exception( |
232 | 232 | 'Cannot append XML fragment', |
233 | 233 | sprintf( |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @param array $attributes |
270 | 270 | * @return \DOMNode |
271 | 271 | */ |
272 | - public function createRoot($name, $attributes=array()) |
|
272 | + public function createRoot($name, $attributes = array()) |
|
273 | 273 | { |
274 | 274 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
275 | 275 | $this->addAttributes($root, $attributes); |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | $string = str_replace('<', 'LT_ESCAPE', $string); |
291 | 291 | $string = str_replace('>', 'GT_ESCAPE', $string); |
292 | 292 | |
293 | - $string = str_replace(' ',' ', $string); |
|
294 | - $string = str_replace('&','&', $string); |
|
293 | + $string = str_replace(' ', ' ', $string); |
|
294 | + $string = str_replace('&', '&', $string); |
|
295 | 295 | |
296 | 296 | return $string; |
297 | 297 | } |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | */ |
307 | 307 | public static function downloadXML($xml, $filename = 'download.xml') |
308 | 308 | { |
309 | - if(!headers_sent() && !self::$simulation) { |
|
310 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
309 | + if (!headers_sent() && !self::$simulation) { |
|
310 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | echo $xml; |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public static function displayXML($xml) |
324 | 324 | { |
325 | - if(!headers_sent() && !self::$simulation) { |
|
325 | + if (!headers_sent() && !self::$simulation) { |
|
326 | 326 | header('Content-Type:text/xml; charset=utf-8'); |
327 | 327 | } |
328 | 328 | |
329 | - if(self::$simulation) { |
|
329 | + if (self::$simulation) { |
|
330 | 330 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
331 | 331 | } |
332 | 332 | |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | * @param string[] $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
345 | 345 | * @see buildErrorXML() |
346 | 346 | */ |
347 | - public static function displayErrorXML($code, $message, $title, $customInfo=array()) |
|
347 | + public static function displayErrorXML($code, $message, $title, $customInfo = array()) |
|
348 | 348 | { |
349 | - if(!headers_sent() && !self::$simulation) { |
|
350 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
349 | + if (!headers_sent() && !self::$simulation) { |
|
350 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | protected static $simulation = false; |
357 | 357 | |
358 | - public static function setSimulation($simulate=true) |
|
358 | + public static function setSimulation($simulate = true) |
|
359 | 359 | { |
360 | 360 | self::$simulation = $simulate; |
361 | 361 | } |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @param string $title |
404 | 404 | * @return string |
405 | 405 | */ |
406 | - public static function buildErrorXML($code, $message, $title, $customInfo=array()) |
|
406 | + public static function buildErrorXML($code, $message, $title, $customInfo = array()) |
|
407 | 407 | { |
408 | 408 | $xml = new \DOMDocument('1.0', 'UTF-8'); |
409 | 409 | $xml->formatOutput = true; |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $helper->addTextTag($root, 'title', $title); |
418 | 418 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
419 | 419 | |
420 | - foreach($customInfo as $name => $value) { |
|
420 | + foreach ($customInfo as $name => $value) { |
|
421 | 421 | $helper->addTextTag($root, $name, $value); |
422 | 422 | } |
423 | 423 |
@@ -14,9 +14,9 @@ |
||
14 | 14 | * @see http://www.xmlsoft.org/html/libxml-xmlerror.html |
15 | 15 | */ |
16 | 16 | |
17 | - /** |
|
18 | - * @var string $list |
|
19 | - */ |
|
17 | + /** |
|
18 | + * @var string $list |
|
19 | + */ |
|
20 | 20 | $list = file_get_contents('libxmlerrors.txt'); |
21 | 21 | $outputFile = 'LibXML.php'; |
22 | 22 | $lines = explode("\n", $list); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $lines = explode("\n", $list); |
23 | 23 | $reverseArray = array(); |
24 | 24 | |
25 | - foreach($lines as $line) |
|
25 | + foreach ($lines as $line) |
|
26 | 26 | { |
27 | 27 | $parts = explode('=', $line); |
28 | 28 | $name = trim(str_replace('XML_ERR_', '', $parts[0])); |