@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function setOption(string $name, $value) |
| 43 | 43 | { |
| 44 | - if(!isset($this->options)) { |
|
| 44 | + if (!isset($this->options)) { |
|
| 45 | 45 | $this->options = $this->getDefaultOptions(); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setOptions(array $options) |
| 60 | 60 | { |
| 61 | - foreach($options as $name => $value) { |
|
| 61 | + foreach ($options as $name => $value) { |
|
| 62 | 62 | $this->setOption($name, $value); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -75,13 +75,13 @@ discard block |
||
| 75 | 75 | * @param mixed $default The default value to return if the option does not exist. |
| 76 | 76 | * @return mixed |
| 77 | 77 | */ |
| 78 | - public function getOption(string $name, $default=null) |
|
| 78 | + public function getOption(string $name, $default = null) |
|
| 79 | 79 | { |
| 80 | - if(!isset($this->options)) { |
|
| 80 | + if (!isset($this->options)) { |
|
| 81 | 81 | $this->options = $this->getDefaultOptions(); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if(isset($this->options[$name])) { |
|
| 84 | + if (isset($this->options[$name])) { |
|
| 85 | 85 | return $this->options[$name]; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @param string $default Used if the option does not exist, is invalid, or empty. |
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | - public function getStringOption(string $name, string $default='') : string |
|
| 101 | + public function getStringOption(string $name, string $default = '') : string |
|
| 102 | 102 | { |
| 103 | 103 | $value = $this->getOption($name, false); |
| 104 | 104 | |
| 105 | - if((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
| 105 | + if ((is_string($value) || is_numeric($value)) && !empty($value)) { |
|
| 106 | 106 | return (string)$value; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | * @param string $name |
| 119 | 119 | * @return bool |
| 120 | 120 | */ |
| 121 | - public function getBoolOption(string $name, bool $default=false) : bool |
|
| 121 | + public function getBoolOption(string $name, bool $default = false) : bool |
|
| 122 | 122 | { |
| 123 | - if($this->getOption($name) === true) { |
|
| 123 | + if ($this->getOption($name) === true) { |
|
| 124 | 124 | return true; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | * @param int $default |
| 137 | 137 | * @return int |
| 138 | 138 | */ |
| 139 | - public function getIntOption(string $name, int $default=0) : int |
|
| 139 | + public function getIntOption(string $name, int $default = 0) : int |
|
| 140 | 140 | { |
| 141 | 141 | $value = $this->getOption($name); |
| 142 | - if(ConvertHelper::isInteger($value)) { |
|
| 142 | + if (ConvertHelper::isInteger($value)) { |
|
| 143 | 143 | return (int)$value; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | public function getArrayOption(string $name) : array |
| 158 | 158 | { |
| 159 | 159 | $val = $this->getOption($name); |
| 160 | - if(is_array($val)) { |
|
| 160 | + if (is_array($val)) { |
|
| 161 | 161 | return $val; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function hasOption(string $name) : bool |
| 175 | 175 | { |
| 176 | - if(!isset($this->options)) { |
|
| 176 | + if (!isset($this->options)) { |
|
| 177 | 177 | $this->options = $this->getDefaultOptions(); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public function getOptions() : array |
| 188 | 188 | { |
| 189 | - if(!isset($this->options)) { |
|
| 189 | + if (!isset($this->options)) { |
|
| 190 | 190 | $this->options = $this->getDefaultOptions(); |
| 191 | 191 | } |
| 192 | 192 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @param mixed $default |
| 241 | 241 | * @return Interface_Optionable |
| 242 | 242 | */ |
| 243 | - function getOption(string $name, $default=null); |
|
| 243 | + function getOption(string $name, $default = null); |
|
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * @param array $options |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // extract parameter names from the query string |
| 38 | 38 | $result = array(); |
| 39 | 39 | preg_match_all('/&?([^&]+)=.*/sixU', $queryString, $result, PREG_PATTERN_ORDER); |
| 40 | - if(isset($result[1])) { |
|
| 40 | + if (isset($result[1])) { |
|
| 41 | 41 | $paramNames = $result[1]; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | // possible naming conflicts like having both parameters "foo.bar" |
| 61 | 61 | // and "foo_bar" in the query string: since "foo.bar" would be converted |
| 62 | 62 | // to "foo_bar", one of the two would be replaced. |
| 63 | - if($fixRequired) |
|
| 63 | + if ($fixRequired) |
|
| 64 | 64 | { |
| 65 | 65 | $counter = 1; |
| 66 | 66 | $placeholders = array(); |
| 67 | - foreach($paramNames as $paramName) |
|
| 67 | + foreach ($paramNames as $paramName) |
|
| 68 | 68 | { |
| 69 | 69 | // create a unique placeholder name |
| 70 | 70 | $placeholder = '__PLACEHOLDER'.$counter.'__'; |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | parse_str($queryString, $parsed); |
| 95 | 95 | |
| 96 | 96 | // do any of the parameter names need to be fixed? |
| 97 | - if(!$fixRequired) { |
|
| 97 | + if (!$fixRequired) { |
|
| 98 | 98 | return $parsed; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $keep = array(); |
| 102 | 102 | |
| 103 | - foreach($parsed as $name => $value) |
|
| 103 | + foreach ($parsed as $name => $value) |
|
| 104 | 104 | { |
| 105 | 105 | $keep[$table[$name]] = $value; |
| 106 | 106 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | return $this->getBoolOption('cut'); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function setCuttingEnabled(bool $enabled=true) : ConvertHelper_WordWrapper |
|
| 66 | + public function setCuttingEnabled(bool $enabled = true) : ConvertHelper_WordWrapper |
|
| 67 | 67 | { |
| 68 | 68 | $this->setOption('cut', $enabled); |
| 69 | 69 | return $this; |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | $interval = $d2->diff($d1); |
| 59 | 59 | |
| 60 | - if($interval === false) |
|
| 60 | + if ($interval === false) |
|
| 61 | 61 | { |
| 62 | 62 | throw new ConvertHelper_Exception( |
| 63 | 63 | 'Cannot create interval', |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | public function __construct() |
| 65 | 65 | { |
| 66 | - if(class_exists('\AppLocalize\Localization')) { |
|
| 66 | + if (class_exists('\AppLocalize\Localization')) { |
|
| 67 | 67 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | $epoch = 'past'; |
| 127 | 127 | $key = 'singular'; |
| 128 | - if($this->dateDiff > 1) { |
|
| 128 | + if ($this->dateDiff > 1) { |
|
| 129 | 129 | $key = 'plural'; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if($this->future) { |
|
| 132 | + if ($this->future) { |
|
| 133 | 133 | $epoch = 'future'; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | protected function initTexts() |
| 144 | 144 | { |
| 145 | - if(isset(self::$texts)) { |
|
| 145 | + if (isset(self::$texts)) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $day = (int)date("j", $this->dateTo); |
| 229 | 229 | $year = (int)date("Y", $this->dateFrom); |
| 230 | 230 | |
| 231 | - while(mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
| 231 | + while (mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
| 232 | 232 | { |
| 233 | 233 | $months_difference++; |
| 234 | 234 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | protected function resolveCalculations() : void |
| 250 | 250 | { |
| 251 | - if(!isset($this->dateFrom)) |
|
| 251 | + if (!isset($this->dateFrom)) |
|
| 252 | 252 | { |
| 253 | 253 | throw new ConvertHelper_Exception( |
| 254 | 254 | 'No date from has been specified.', |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // no date to set? Assume we want to use today. |
| 261 | - if(!isset($this->dateTo)) |
|
| 261 | + if (!isset($this->dateTo)) |
|
| 262 | 262 | { |
| 263 | 263 | $this->dateTo = time(); |
| 264 | 264 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | $difference = $this->dateTo - $this->dateFrom; |
| 339 | 339 | |
| 340 | - if($difference < 0) |
|
| 340 | + if ($difference < 0) |
|
| 341 | 341 | { |
| 342 | 342 | $difference = $difference * -1; |
| 343 | 343 | $this->future = true; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function __construct() |
| 38 | 38 | { |
| 39 | - if(class_exists('\AppLocalize\Localization')) { |
|
| 39 | + if (class_exists('\AppLocalize\Localization')) { |
|
| 40 | 40 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | $keep = $this->resolveTokens($interval); |
| 70 | 70 | |
| 71 | 71 | $parts = array(); |
| 72 | - foreach($keep as $token) |
|
| 72 | + foreach ($keep as $token) |
|
| 73 | 73 | { |
| 74 | 74 | $value = $interval->getToken($token); |
| 75 | - if($value === 0) { |
|
| 75 | + if ($value === 0) { |
|
| 76 | 76 | continue; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $parts[] = $this->translateToken($token, $interval); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(count($parts) == 1) { |
|
| 82 | + if (count($parts) == 1) { |
|
| 83 | 83 | return $parts[0]; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | $value = $interval->getToken($token); |
| 102 | 102 | |
| 103 | 103 | $suffix = 'p'; |
| 104 | - if($value == 1) { $suffix = 's'; } |
|
| 104 | + if ($value == 1) { $suffix = 's'; } |
|
| 105 | 105 | $token .= $suffix; |
| 106 | 106 | |
| 107 | - if(!isset(self::$texts[$token])) |
|
| 107 | + if (!isset(self::$texts[$token])) |
|
| 108 | 108 | { |
| 109 | 109 | throw new ConvertHelper_Exception( |
| 110 | 110 | 'Missing interval translation', |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $offset = 0; |
| 136 | 136 | |
| 137 | - foreach($this->tokens as $token) |
|
| 137 | + foreach ($this->tokens as $token) |
|
| 138 | 138 | { |
| 139 | - if($interval->getToken($token) > 0) |
|
| 139 | + if ($interval->getToken($token) > 0) |
|
| 140 | 140 | { |
| 141 | 141 | return array_slice($this->tokens, $offset); |
| 142 | 142 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function initTexts() : void |
| 154 | 154 | { |
| 155 | - if(isset(self::$texts)) { |
|
| 155 | + if (isset(self::$texts)) { |
|
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | const ERROR_OPENING_ZIP_FILE = 338003; |
| 32 | 32 | |
| 33 | - const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
| 33 | + const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
| 34 | 34 | |
| 35 | 35 | protected $options = array( |
| 36 | 36 | 'WriteThreshold' => 100 |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
| 82 | 82 | */ |
| 83 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
| 83 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
| 84 | 84 | { |
| 85 | 85 | $this->open(); |
| 86 | 86 | |
@@ -126,16 +126,16 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | protected function open() |
| 128 | 128 | { |
| 129 | - if($this->open) { |
|
| 129 | + if ($this->open) { |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if(!isset($this->zip)) { |
|
| 133 | + if (!isset($this->zip)) { |
|
| 134 | 134 | $this->zip = new \ZipArchive(); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | $flag = null; |
| 138 | - if(!file_exists($this->file)) { |
|
| 138 | + if (!file_exists($this->file)) { |
|
| 139 | 139 | $flag = \ZipArchive::CREATE; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | { |
| 176 | 176 | $this->fileTracker++; |
| 177 | 177 | |
| 178 | - if($this->options['WriteThreshold'] < 1) { |
|
| 178 | + if ($this->options['WriteThreshold'] < 1) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | protected function close() |
| 190 | 190 | { |
| 191 | - if(!$this->open) { |
|
| 191 | + if (!$this->open) { |
|
| 192 | 192 | return; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | throw new ZIPHelper_Exception( |
| 198 | 198 | 'Could not save ZIP file to disk', |
| 199 | 199 | sprintf( |
| 200 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
| 201 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
| 200 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
| 201 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
| 202 | 202 | 'or trying to save to a directory that does not exist.', |
| 203 | 203 | $this->file |
| 204 | 204 | ), |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | { |
| 214 | 214 | $this->open(); |
| 215 | 215 | |
| 216 | - if($this->countFiles() < 1) |
|
| 216 | + if ($this->countFiles() < 1) |
|
| 217 | 217 | { |
| 218 | 218 | throw new ZIPHelper_Exception( |
| 219 | 219 | 'No files in the zip file', |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | * @throws ZIPHelper_Exception |
| 238 | 238 | * @return string The file name that was sent (useful in case none was specified). |
| 239 | 239 | */ |
| 240 | - public function download(?string $fileName=null) : string |
|
| 240 | + public function download(?string $fileName = null) : string |
|
| 241 | 241 | { |
| 242 | 242 | $this->save(); |
| 243 | 243 | |
| 244 | - if(empty($fileName)) { |
|
| 244 | + if (empty($fileName)) { |
|
| 245 | 245 | $fileName = basename($this->file); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | header('Content-type: application/zip'); |
| 249 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
| 250 | - header('Content-length: ' . filesize($this->file)); |
|
| 249 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
| 250 | + header('Content-length: '.filesize($this->file)); |
|
| 251 | 251 | header('Pragma: no-cache'); |
| 252 | 252 | header('Expires: 0'); |
| 253 | 253 | readfile($this->file); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param string|NULL $fileName Override the ZIP's file name for the download |
| 263 | 263 | * @see ZIPHelper::download() |
| 264 | 264 | */ |
| 265 | - public function downloadAndDelete(?string $fileName=null) |
|
| 265 | + public function downloadAndDelete(?string $fileName = null) |
|
| 266 | 266 | { |
| 267 | 267 | $this->download($fileName); |
| 268 | 268 | |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
| 278 | 278 | * @return boolean |
| 279 | 279 | */ |
| 280 | - public function extractAll(?string $outputFolder=null) : bool |
|
| 280 | + public function extractAll(?string $outputFolder = null) : bool |
|
| 281 | 281 | { |
| 282 | - if(empty($outputFolder)) { |
|
| 282 | + if (empty($outputFolder)) { |
|
| 283 | 283 | $outputFolder = dirname($this->file); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | $this->commandLine = $commandLine; |
| 42 | 42 | $this->output = $output; |
| 43 | 43 | |
| 44 | - foreach($errors as $error) { |
|
| 45 | - if($error->isError()) { |
|
| 44 | + foreach ($errors as $error) { |
|
| 45 | + if ($error->isError()) { |
|
| 46 | 46 | $this->errors[] = $error; |
| 47 | 47 | } else { |
| 48 | 48 | $this->warnings[] = $error; |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public function hasErrorCode($code) |
| 64 | 64 | { |
| 65 | - foreach($this->errors as $error) { |
|
| 66 | - if($error->getCode() == $code) { |
|
| 65 | + foreach ($this->errors as $error) { |
|
| 66 | + if ($error->getCode() == $code) { |
|
| 67 | 67 | return true; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | * @param bool $asString |
| 93 | 93 | * @return string|string[] |
| 94 | 94 | */ |
| 95 | - public function getErrorMessages(bool $asString=false) |
|
| 95 | + public function getErrorMessages(bool $asString = false) |
|
| 96 | 96 | { |
| 97 | - if($asString) { |
|
| 97 | + if ($asString) { |
|
| 98 | 98 | $lines = array(); |
| 99 | - foreach($this->errors as $error) { |
|
| 99 | + foreach ($this->errors as $error) { |
|
| 100 | 100 | $lines[] = (string)$error; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $messages = array(); |
| 107 | - foreach($this->errors as $error) { |
|
| 107 | + foreach ($this->errors as $error) { |
|
| 108 | 108 | $messages[] = (string)$error; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | public function getLastLine() |
| 125 | 125 | { |
| 126 | - return $this->output[count($this->output)-1]; |
|
| 126 | + return $this->output[count($this->output) - 1]; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public function getFirstLine() |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | public function isConnectionFailed() |
| 140 | 140 | { |
| 141 | - foreach($this->errors as $error) { |
|
| 142 | - if($error->isConnectionFailed()) { |
|
| 141 | + foreach ($this->errors as $error) { |
|
| 142 | + if ($error->isConnectionFailed()) { |
|
| 143 | 143 | return true; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function hasConflicts() |
| 151 | 151 | { |
| 152 | - foreach($this->errors as $error) { |
|
| 153 | - if($error->isConflict()) { |
|
| 152 | + foreach ($this->errors as $error) { |
|
| 153 | + if ($error->isConflict()) { |
|
| 154 | 154 | return true; |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | public function hasLocks() |
| 162 | 162 | { |
| 163 | - foreach($this->errors as $error) { |
|
| 164 | - if($error->isLock()) { |
|
| 163 | + foreach ($this->errors as $error) { |
|
| 164 | + if ($error->isLock()) { |
|
| 165 | 165 | return true; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function addAttribute($parent, string $name, $value) |
| 110 | 110 | { |
| 111 | - if(!$parent instanceof \DOMNode) { |
|
| 111 | + if (!$parent instanceof \DOMNode) { |
|
| 112 | 112 | throw new XMLHelper_Exception( |
| 113 | 113 | 'The specified parent node is not a node instance.', |
| 114 | 114 | sprintf('Tried adding attribute [%s].', $name), |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | if (!empty($text)) { |
| 232 | 232 | $fragment = $this->dom->createDocumentFragment(); |
| 233 | - if(!@$fragment->appendXML($text)) { |
|
| 233 | + if (!@$fragment->appendXML($text)) { |
|
| 234 | 234 | throw new XMLHelper_Exception( |
| 235 | 235 | 'Cannot append XML fragment', |
| 236 | 236 | sprintf( |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param array $attributes |
| 273 | 273 | * @return \DOMNode |
| 274 | 274 | */ |
| 275 | - public function createRoot($name, $attributes=array()) |
|
| 275 | + public function createRoot($name, $attributes = array()) |
|
| 276 | 276 | { |
| 277 | 277 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
| 278 | 278 | $this->addAttributes($root, $attributes); |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | $string = str_replace('<', 'LT_ESCAPE', $string); |
| 294 | 294 | $string = str_replace('>', 'GT_ESCAPE', $string); |
| 295 | 295 | |
| 296 | - $string = str_replace(' ',' ', $string); |
|
| 297 | - $string = str_replace('&','&', $string); |
|
| 296 | + $string = str_replace(' ', ' ', $string); |
|
| 297 | + $string = str_replace('&', '&', $string); |
|
| 298 | 298 | |
| 299 | 299 | return $string; |
| 300 | 300 | } |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | */ |
| 310 | 310 | public static function downloadXML($xml, $filename = 'download.xml') |
| 311 | 311 | { |
| 312 | - if(!headers_sent() && !self::$simulation) { |
|
| 313 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 312 | + if (!headers_sent() && !self::$simulation) { |
|
| 313 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | echo $xml; |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public static function displayXML($xml) |
| 327 | 327 | { |
| 328 | - if(!headers_sent() && !self::$simulation) { |
|
| 328 | + if (!headers_sent() && !self::$simulation) { |
|
| 329 | 329 | header('Content-Type:text/xml; charset=utf-8'); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if(self::$simulation) { |
|
| 332 | + if (self::$simulation) { |
|
| 333 | 333 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
| 334 | 334 | } |
| 335 | 335 | |
@@ -347,10 +347,10 @@ discard block |
||
| 347 | 347 | * @param string[] $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
| 348 | 348 | * @see buildErrorXML() |
| 349 | 349 | */ |
| 350 | - public static function displayErrorXML($code, $message, $title, $customInfo=array()) |
|
| 350 | + public static function displayErrorXML($code, $message, $title, $customInfo = array()) |
|
| 351 | 351 | { |
| 352 | - if(!headers_sent() && !self::$simulation) { |
|
| 353 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
| 352 | + if (!headers_sent() && !self::$simulation) { |
|
| 353 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | protected static $simulation = false; |
| 360 | 360 | |
| 361 | - public static function setSimulation($simulate=true) |
|
| 361 | + public static function setSimulation($simulate = true) |
|
| 362 | 362 | { |
| 363 | 363 | self::$simulation = $simulate; |
| 364 | 364 | } |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param string $title |
| 407 | 407 | * @return string |
| 408 | 408 | */ |
| 409 | - public static function buildErrorXML($code, $message, $title, $customInfo=array()) |
|
| 409 | + public static function buildErrorXML($code, $message, $title, $customInfo = array()) |
|
| 410 | 410 | { |
| 411 | 411 | $xml = new \DOMDocument('1.0', 'UTF-8'); |
| 412 | 412 | $xml->formatOutput = true; |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $helper->addTextTag($root, 'title', $title); |
| 421 | 421 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
| 422 | 422 | |
| 423 | - foreach($customInfo as $name => $value) { |
|
| 423 | + foreach ($customInfo as $name => $value) { |
|
| 424 | 424 | $helper->addTextTag($root, $name, $value); |
| 425 | 425 | } |
| 426 | 426 | |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | public static function string2xml(string $string) : string |
| 467 | 467 | { |
| 468 | - if(stristr($string, '<body')) |
|
| 468 | + if (stristr($string, '<body')) |
|
| 469 | 469 | { |
| 470 | 470 | throw new XMLHelper_Exception( |
| 471 | 471 | 'Cannot convert string with existing body element', |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | // capture all elements except the body tag itself |
| 497 | 497 | $xml = ''; |
| 498 | - foreach($root->childNodes as $child) { |
|
| 498 | + foreach ($root->childNodes as $child) { |
|
| 499 | 499 | $xml .= $dom->saveXML($child); |
| 500 | 500 | } |
| 501 | 501 | |