@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | $info = FileHelper::getFolderInfo($rootFolder); |
24 | 24 | |
25 | - if(!$info->exists()) |
|
25 | + if (!$info->exists()) |
|
26 | 26 | { |
27 | 27 | return true; |
28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | foreach ($d as $item) |
33 | 33 | { |
34 | - if(self::processDeleteItem($item) === false) |
|
34 | + if (self::processDeleteItem($item) === false) |
|
35 | 35 | { |
36 | 36 | return false; |
37 | 37 | } |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | { |
101 | 101 | $target = FileHelper::createFolder($target); |
102 | 102 | |
103 | - $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator(); |
|
103 | + $d = FileHelper::getPathInfo($source)->requireIsFolder()->getIterator(); |
|
104 | 104 | |
105 | 105 | foreach ($d as $item) |
106 | 106 | { |
107 | - if($item->isDot()) |
|
107 | + if ($item->isDot()) |
|
108 | 108 | { |
109 | 109 | continue; |
110 | 110 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | if ($item->isFolder()) |
127 | 127 | { |
128 | - self::copy($item, $target . '/' . $item->getName()); |
|
128 | + self::copy($item, $target.'/'.$item->getName()); |
|
129 | 129 | } |
130 | - else if($item->isFile()) |
|
130 | + else if ($item->isFile()) |
|
131 | 131 | { |
132 | 132 | $item |
133 | 133 | ->requireIsFile() |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function fromString($string) : bool |
31 | 31 | { |
32 | - if($string === '' || !is_scalar($string)) |
|
32 | + if ($string === '' || !is_scalar($string)) |
|
33 | 33 | { |
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | |
37 | - if(is_bool($string)) |
|
37 | + if (is_bool($string)) |
|
38 | 38 | { |
39 | 39 | return $string; |
40 | 40 | } |
41 | 41 | |
42 | - if(is_string($string)) |
|
42 | + if (is_string($string)) |
|
43 | 43 | { |
44 | 44 | $string = strtolower($string); |
45 | 45 | } |
46 | 46 | |
47 | - if(array_key_exists($string, self::$booleanStrings)) |
|
47 | + if (array_key_exists($string, self::$booleanStrings)) |
|
48 | 48 | { |
49 | 49 | return self::$booleanStrings[$string]; |
50 | 50 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public static function toString($boolean, bool $yesno = false) : string |
75 | 75 | { |
76 | 76 | // allow 'yes', 'true', 'no', 'false' string notations as well |
77 | - if(!is_bool($boolean)) { |
|
77 | + if (!is_bool($boolean)) { |
|
78 | 78 | $boolean = self::fromString($boolean); |
79 | 79 | } |
80 | 80 | |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public static function isBoolean($value) : bool |
132 | 132 | { |
133 | - if(is_bool($value)) { |
|
133 | + if (is_bool($value)) { |
|
134 | 134 | return true; |
135 | 135 | } |
136 | 136 | |
137 | - if(!is_scalar($value)) { |
|
137 | + if (!is_scalar($value)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | public static function detectMimeType($fileName) : ?string |
209 | 209 | { |
210 | 210 | $ext = self::getExtension($fileName); |
211 | - if(empty($ext)) { |
|
211 | + if (empty($ext)) { |
|
212 | 212 | return null; |
213 | 213 | } |
214 | 214 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
253 | 253 | * @see FileHelper::ERROR_UNKNOWN_FILE_MIME_TYPE |
254 | 254 | */ |
255 | - public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment=true) : void |
|
255 | + public static function sendFile($filePath, ?string $fileName = null, bool $asAttachment = true) : void |
|
256 | 256 | { |
257 | 257 | self::getFileInfo($filePath)->getDownloader()->send($fileName, $asAttachment); |
258 | 258 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @throws FileHelper_Exception |
270 | 270 | * @see FileHelper::ERROR_CANNOT_OPEN_URL |
271 | 271 | */ |
272 | - public static function downloadFile(string $url, int $timeout=0, bool $SSLEnabled=false) : string |
|
272 | + public static function downloadFile(string $url, int $timeout = 0, bool $SSLEnabled = false) : string |
|
273 | 273 | { |
274 | 274 | return FileDownloader::factory($url) |
275 | 275 | ->setTimeout($timeout) |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | { |
325 | 325 | $info = self::getPathInfo($pathOrDirIterator); |
326 | 326 | |
327 | - if($extension === true || $info instanceof FolderInfo) |
|
327 | + if ($extension === true || $info instanceof FolderInfo) |
|
328 | 328 | { |
329 | 329 | return $info->getName(); |
330 | 330 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE |
347 | 347 | * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE |
348 | 348 | */ |
349 | - public static function parseJSONFile($file, string $targetEncoding='', $sourceEncoding=null) : array |
|
349 | + public static function parseJSONFile($file, string $targetEncoding = '', $sourceEncoding = null) : array |
|
350 | 350 | { |
351 | 351 | return JSONFile::factory($file) |
352 | 352 | ->setTargetEncoding($targetEncoding) |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @throws FileHelper_Exception |
400 | 400 | * @see FileHelper::createFileFinder() |
401 | 401 | */ |
402 | - public static function findHTMLFiles($targetFolder, array $options=array()) : array |
|
402 | + public static function findHTMLFiles($targetFolder, array $options = array()) : array |
|
403 | 403 | { |
404 | 404 | return self::findFiles($targetFolder, array('html'), $options); |
405 | 405 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @throws FileHelper_Exception |
419 | 419 | * @see FileHelper::createFileFinder() |
420 | 420 | */ |
421 | - public static function findPHPFiles($targetFolder, array $options=array()) : array |
|
421 | + public static function findPHPFiles($targetFolder, array $options = array()) : array |
|
422 | 422 | { |
423 | 423 | return self::findFiles($targetFolder, array('php'), $options); |
424 | 424 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @see FileHelper::createFileFinder() |
441 | 441 | * @deprecated Use the file finder instead. |
442 | 442 | */ |
443 | - public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
|
443 | + public static function findFiles($targetFolder, array $extensions = array(), array $options = array()) : array |
|
444 | 444 | { |
445 | 445 | $finder = self::createFileFinder($targetFolder); |
446 | 446 | |
@@ -450,16 +450,16 @@ discard block |
||
450 | 450 | |
451 | 451 | $finder->setPathmodeStrip(); |
452 | 452 | |
453 | - if(isset($options['relative-path']) && $options['relative-path'] === true) |
|
453 | + if (isset($options['relative-path']) && $options['relative-path'] === true) |
|
454 | 454 | { |
455 | 455 | $finder->setPathmodeRelative(); |
456 | 456 | } |
457 | - else if(isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
457 | + else if (isset($options['absolute-path']) && $options['absolute-path'] === true) |
|
458 | 458 | { |
459 | 459 | $finder->setPathmodeAbsolute(); |
460 | 460 | } |
461 | 461 | |
462 | - if(isset($options['strip-extension'])) |
|
462 | + if (isset($options['strip-extension'])) |
|
463 | 463 | { |
464 | 464 | $finder->stripExtensions(); |
465 | 465 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @return string |
479 | 479 | * @throws FileHelper_Exception |
480 | 480 | */ |
481 | - public static function removeExtension($filename, bool $keepPath=false) : string |
|
481 | + public static function removeExtension($filename, bool $keepPath = false) : string |
|
482 | 482 | { |
483 | 483 | return self::getFileInfo($filename)->removeExtension($keepPath); |
484 | 484 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | public static function createUnicodeHandling() : UnicodeHandling |
492 | 492 | { |
493 | - if(!isset(self::$unicodeHandling)) |
|
493 | + if (!isset(self::$unicodeHandling)) |
|
494 | 494 | { |
495 | 495 | self::$unicodeHandling = new UnicodeHandling(); |
496 | 496 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
525 | 525 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
526 | 526 | */ |
527 | - public static function saveAsJSON($data, $file, bool $pretty=false) : JSONFile |
|
527 | + public static function saveAsJSON($data, $file, bool $pretty = false) : JSONFile |
|
528 | 528 | { |
529 | 529 | return JSONFile::factory($file)->putData($data, $pretty); |
530 | 530 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
543 | 543 | * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
544 | 544 | */ |
545 | - public static function saveFile($filePath, string $content='') : FileInfo |
|
545 | + public static function saveFile($filePath, string $content = '') : FileInfo |
|
546 | 546 | { |
547 | 547 | return self::getFileInfo($filePath)->putContents($content); |
548 | 548 | } |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @param int $depth The folder depth to reduce the path to |
655 | 655 | * @return string |
656 | 656 | */ |
657 | - public static function relativizePathByDepth(string $path, int $depth=2) : string |
|
657 | + public static function relativizePathByDepth(string $path, int $depth = 2) : string |
|
658 | 658 | { |
659 | 659 | return PathRelativizer::relativizeByDepth($path, $depth); |
660 | 660 | } |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
694 | 694 | * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
695 | 695 | */ |
696 | - public static function requireFileExists($path, ?int $errorCode=null) : string |
|
696 | + public static function requireFileExists($path, ?int $errorCode = null) : string |
|
697 | 697 | { |
698 | 698 | return self::getPathInfo($path) |
699 | 699 | ->requireIsFile() |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @return string |
708 | 708 | * @throws FileHelper_Exception |
709 | 709 | */ |
710 | - public static function requireFileReadable($path, ?int $errorCode=null) : string |
|
710 | + public static function requireFileReadable($path, ?int $errorCode = null) : string |
|
711 | 711 | { |
712 | 712 | return self::getPathInfo($path) |
713 | 713 | ->requireIsFile() |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
786 | 786 | * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES |
787 | 787 | */ |
788 | - public static function readLines($filePath, int $amount=0) : array |
|
788 | + public static function readLines($filePath, int $amount = 0) : array |
|
789 | 789 | { |
790 | 790 | return self::getFileInfo($filePath) |
791 | 791 | ->getLineReader() |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * |
836 | 836 | * @throws FileHelper_Exception |
837 | 837 | */ |
838 | - public static function createPathsReducer(array $paths=array()) : PathsReducer |
|
838 | + public static function createPathsReducer(array $paths = array()) : PathsReducer |
|
839 | 839 | { |
840 | 840 | return new PathsReducer($paths); |
841 | 841 | } |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public static function factory($path) : JSONFile |
45 | 45 | { |
46 | - if($path instanceof self) { |
|
46 | + if ($path instanceof self) { |
|
47 | 47 | return $path; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $instance = self::createInstance($path); |
51 | 51 | |
52 | - if($instance instanceof self) { |
|
52 | + if ($instance instanceof self) { |
|
53 | 53 | return $instance; |
54 | 54 | } |
55 | 55 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | private function convertEncoding(string $contents) : string |
130 | 130 | { |
131 | - if(!empty($this->targetEncoding)) |
|
131 | + if (!empty($this->targetEncoding)) |
|
132 | 132 | { |
133 | 133 | return (string)mb_convert_encoding( |
134 | 134 | $contents, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $options = null; |
152 | 152 | |
153 | - if($pretty) |
|
153 | + if ($pretty) |
|
154 | 154 | { |
155 | 155 | $options = JSON_PRETTY_PRINT; |
156 | 156 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | $path = realpath($this->path); |
98 | 98 | |
99 | - if($path !== false) |
|
99 | + if ($path !== false) |
|
100 | 100 | { |
101 | 101 | return FileHelper::normalizePath($path); |
102 | 102 | } |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @return $this |
116 | 116 | * @throws FileHelper_Exception |
117 | 117 | */ |
118 | - private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode=null) : self |
|
118 | + private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode = null) : self |
|
119 | 119 | { |
120 | - if($condition === true) |
|
120 | + if ($condition === true) |
|
121 | 121 | { |
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - if($errorCode === null) |
|
125 | + if ($errorCode === null) |
|
126 | 126 | { |
127 | 127 | $errorCode = FileHelper::ERROR_FILE_DOES_NOT_EXIST; |
128 | 128 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @return $this |
140 | 140 | * @throws FileHelper_Exception |
141 | 141 | */ |
142 | - public function requireExists(?int $errorCode=null) : self |
|
142 | + public function requireExists(?int $errorCode = null) : self |
|
143 | 143 | { |
144 | 144 | return $this->requireTrue( |
145 | 145 | !empty($this->path) && realpath($this->path) !== false, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return $this |
154 | 154 | * @throws FileHelper_Exception |
155 | 155 | */ |
156 | - public function requireReadable(?int $errorCode=null) : self |
|
156 | + public function requireReadable(?int $errorCode = null) : self |
|
157 | 157 | { |
158 | 158 | $this->requireExists($errorCode); |
159 | 159 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return $this |
170 | 170 | * @throws FileHelper_Exception |
171 | 171 | */ |
172 | - public function requireWritable(?int $errorCode=null) : self |
|
172 | + public function requireWritable(?int $errorCode = null) : self |
|
173 | 173 | { |
174 | 174 | return $this->requireTrue( |
175 | 175 | $this->isWritable(), |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function requireIsFile() : FileInfo |
188 | 188 | { |
189 | - if($this instanceof FileInfo) |
|
189 | + if ($this instanceof FileInfo) |
|
190 | 190 | { |
191 | 191 | return $this; |
192 | 192 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public function requireIsFolder() : FolderInfo |
211 | 211 | { |
212 | - if($this instanceof FolderInfo) |
|
212 | + if ($this instanceof FolderInfo) |
|
213 | 213 | { |
214 | 214 | return $this; |
215 | 215 | } |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public static function type2string($path) : string |
232 | 232 | { |
233 | - if($path instanceof PathInfoInterface) |
|
233 | + if ($path instanceof PathInfoInterface) |
|
234 | 234 | { |
235 | 235 | return $path->getPath(); |
236 | 236 | } |
237 | 237 | |
238 | - if($path instanceof SplFileInfo) |
|
238 | + if ($path instanceof SplFileInfo) |
|
239 | 239 | { |
240 | 240 | return $path->getPathname(); |
241 | 241 | } |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public static function resolveType($path) : PathInfoInterface |
259 | 259 | { |
260 | - if($path instanceof PathInfoInterface) |
|
260 | + if ($path instanceof PathInfoInterface) |
|
261 | 261 | { |
262 | 262 | return $path; |
263 | 263 | } |
264 | 264 | |
265 | 265 | $path = self::type2string($path); |
266 | 266 | |
267 | - if(FolderInfo::is_dir($path)) |
|
267 | + if (FolderInfo::is_dir($path)) |
|
268 | 268 | { |
269 | 269 | return FolderInfo::factory($path); |
270 | 270 | } |
271 | 271 | |
272 | - if(FileInfo::is_file($path)) |
|
272 | + if (FileInfo::is_file($path)) |
|
273 | 273 | { |
274 | 274 | return FileInfo::factory($path); |
275 | 275 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | public function getModifiedDate() : ?DateTime |
328 | 328 | { |
329 | 329 | $time = filemtime($this->getPath()); |
330 | - if($time === false) { |
|
330 | + if ($time === false) { |
|
331 | 331 | return null; |
332 | 332 | } |
333 | 333 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | interface PathInfoInterface |
25 | 25 | { |
26 | 26 | public function getName() : string; |
27 | - public function getExtension(bool $lowercase=true) : string; |
|
27 | + public function getExtension(bool $lowercase = true) : string; |
|
28 | 28 | public function getPath() : string; |
29 | 29 | public function getFolderPath() : string; |
30 | 30 | public function exists() : bool; |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function factory($path) : SerializedFile |
34 | 34 | { |
35 | - if($path instanceof self) { |
|
35 | + if ($path instanceof self) { |
|
36 | 36 | return $path; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $instance = self::createInstance($path); |
40 | 40 | |
41 | - if($instance instanceof self) { |
|
41 | + if ($instance instanceof self) { |
|
42 | 42 | return $instance; |
43 | 43 | } |
44 | 44 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | ) |
74 | 74 | ); |
75 | 75 | |
76 | - if($result !== false) { |
|
76 | + if ($result !== false) { |
|
77 | 77 | return $result; |
78 | 78 | } |
79 | 79 |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function factory($path) : PHPFile |
34 | 34 | { |
35 | - if($path instanceof self) { |
|
35 | + if ($path instanceof self) { |
|
36 | 36 | return $path; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $instance = self::createInstance($path); |
40 | 40 | |
41 | - if($instance instanceof self) { |
|
41 | + if ($instance instanceof self) { |
|
42 | 42 | return $instance; |
43 | 43 | } |
44 | 44 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function checkSyntax() |
61 | 61 | { |
62 | - if(!FileHelper::canMakePHPCalls()) |
|
62 | + if (!FileHelper::canMakePHPCalls()) |
|
63 | 63 | { |
64 | 64 | return true; |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | // when the validation is successful, the first entry |
72 | 72 | // in the array contains the success message. When it |
73 | 73 | // is invalid, the first entry is always empty. |
74 | - if(!empty($output[0])) { |
|
74 | + if (!empty($output[0])) { |
|
75 | 75 | return true; |
76 | 76 | } |
77 | 77 |
@@ -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 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | if (!empty($text)) { |
248 | 248 | $fragment = $this->dom->createDocumentFragment(); |
249 | - if(!@$fragment->appendXML($text)) { |
|
249 | + if (!@$fragment->appendXML($text)) { |
|
250 | 250 | throw new XMLHelper_Exception( |
251 | 251 | 'Cannot append XML fragment', |
252 | 252 | sprintf( |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param array<string,mixed> $attributes |
289 | 289 | * @return DOMNode |
290 | 290 | */ |
291 | - public function createRoot(string $name, array $attributes=array()) |
|
291 | + public function createRoot(string $name, array $attributes = array()) |
|
292 | 292 | { |
293 | 293 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
294 | 294 | $this->addAttributes($root, $attributes); |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | $string = str_replace('<', 'LT_ESCAPE', $string); |
315 | 315 | $string = str_replace('>', 'GT_ESCAPE', $string); |
316 | 316 | |
317 | - $string = str_replace(' ',' ', $string); |
|
318 | - $string = str_replace('&','&', $string); |
|
317 | + $string = str_replace(' ', ' ', $string); |
|
318 | + $string = str_replace('&', '&', $string); |
|
319 | 319 | |
320 | 320 | return $string; |
321 | 321 | } |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
336 | 336 | { |
337 | - if(!headers_sent() && !self::$simulation) |
|
337 | + if (!headers_sent() && !self::$simulation) |
|
338 | 338 | { |
339 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
339 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | echo $xml; |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public static function displayXML(string $xml) : void |
352 | 352 | { |
353 | - if(!headers_sent() && !self::$simulation) |
|
353 | + if (!headers_sent() && !self::$simulation) |
|
354 | 354 | { |
355 | 355 | header('Content-Type:text/xml; charset=utf-8'); |
356 | 356 | } |
357 | 357 | |
358 | - if(self::$simulation) |
|
358 | + if (self::$simulation) |
|
359 | 359 | { |
360 | 360 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
361 | 361 | } |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | * @param array<string,string> $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
374 | 374 | * @see buildErrorXML() |
375 | 375 | */ |
376 | - public static function displayErrorXML($code, string $message, string $title, array $customInfo=array()) |
|
376 | + public static function displayErrorXML($code, string $message, string $title, array $customInfo = array()) |
|
377 | 377 | { |
378 | - if(!headers_sent() && !self::$simulation) { |
|
379 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
378 | + if (!headers_sent() && !self::$simulation) { |
|
379 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
383 | 383 | } |
384 | 384 | |
385 | - public static function setSimulation(bool $simulate=true) : void |
|
385 | + public static function setSimulation(bool $simulate = true) : void |
|
386 | 386 | { |
387 | 387 | self::$simulation = $simulate; |
388 | 388 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @param array<string,string> $customInfo |
432 | 432 | * @return string |
433 | 433 | */ |
434 | - public static function buildErrorXML($code, string $message, string $title, array $customInfo=array()) |
|
434 | + public static function buildErrorXML($code, string $message, string $title, array $customInfo = array()) |
|
435 | 435 | { |
436 | 436 | $xml = new DOMDocument('1.0', 'UTF-8'); |
437 | 437 | $xml->formatOutput = true; |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | $helper->addTextTag($root, 'title', $title); |
446 | 446 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
447 | 447 | |
448 | - foreach($customInfo as $name => $value) { |
|
448 | + foreach ($customInfo as $name => $value) { |
|
449 | 449 | $helper->addTextTag($root, $name, $value); |
450 | 450 | } |
451 | 451 |