@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param $filename |
82 | 82 | */ |
83 | - public function setFileName($filename){ |
|
83 | + public function setFileName($filename) { |
|
84 | 84 | $this->_fileName = $filename; |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @param $encoding |
91 | 91 | */ |
92 | - public function setEncoding($encoding){ |
|
92 | + public function setEncoding($encoding) { |
|
93 | 93 | $this->_encoding = $encoding; |
94 | 94 | } |
95 | 95 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param $fileNamePrefix |
100 | 100 | */ |
101 | - public function setFileNamePrefix($fileNamePrefix){ |
|
101 | + public function setFileNamePrefix($fileNamePrefix) { |
|
102 | 102 | $this->_fileNamePrefix = $fileNamePrefix; |
103 | 103 | } |
104 | 104 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param $writeMode |
109 | 109 | * @see https://secure.php.net/manual/en/function.fopen.php |
110 | 110 | */ |
111 | - public function setWriteMode($writeMode){ |
|
111 | + public function setWriteMode($writeMode) { |
|
112 | 112 | $this->_writeMode = $writeMode; |
113 | 113 | } |
114 | 114 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param $compressed bool |
119 | 119 | */ |
120 | - public function setIsCompressed($isCompressed){ |
|
120 | + public function setIsCompressed($isCompressed) { |
|
121 | 121 | $this->_isCompressed = $isCompressed; |
122 | 122 | } |
123 | 123 | |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @param string $fileHeader |
129 | 129 | */ |
130 | - public function setHeader($fileHeader = null){ |
|
130 | + public function setHeader($fileHeader = null) { |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Set standard XML header if not defined |
134 | 134 | */ |
135 | - if($fileHeader === null){ |
|
136 | - $this->_fileHeader = '<?xml version="1.0" encoding="' . $this->_encoding .'"?>'; |
|
135 | + if ($fileHeader === null) { |
|
136 | + $this->_fileHeader = '<?xml version="1.0" encoding="' . $this->_encoding . '"?>'; |
|
137 | 137 | } |
138 | - else{ |
|
138 | + else { |
|
139 | 139 | $this->_fileHeader = $fileHeader; |
140 | 140 | } |
141 | 141 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function getFileName(){ |
|
148 | + public function getFileName() { |
|
149 | 149 | return $this->_fileName; |
150 | 150 | } |
151 | 151 | |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * Generate filename if needed |
176 | 176 | */ |
177 | - if($fileName === null){ |
|
177 | + if ($fileName === null) { |
|
178 | 178 | $this->setFileName(tempnam(sys_get_temp_dir(), $this->_fileNamePrefix)); |
179 | 179 | } |
180 | - else{ |
|
180 | + else { |
|
181 | 181 | $this->setFileName($fileName); |
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Autoopen file if needed |
186 | 186 | */ |
187 | - if($autoOpenFile === true) { |
|
187 | + if ($autoOpenFile === true) { |
|
188 | 188 | $this->openFile(); |
189 | 189 | } |
190 | 190 | } |
@@ -202,15 +202,15 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * Open XML file |
204 | 204 | */ |
205 | - public function openFile($autoAddHeader = true){ |
|
205 | + public function openFile($autoAddHeader = true) { |
|
206 | 206 | try { |
207 | 207 | $this->_filePointer = fopen($this->_fileName, $this->_writeMode); |
208 | 208 | } |
209 | - catch (\Exception $e){ |
|
209 | + catch (\Exception $e) { |
|
210 | 210 | die('File cannot be opened: ' . $e->getMessage()); |
211 | 211 | } |
212 | 212 | |
213 | - if($autoAddHeader === true){ |
|
213 | + if ($autoAddHeader === true) { |
|
214 | 214 | $this->writeHeader(); |
215 | 215 | } |
216 | 216 | } |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * Close XML file if is opened |
220 | 220 | */ |
221 | - public function closeFile(){ |
|
222 | - if(is_resource($this->_filePointer) === true){ |
|
221 | + public function closeFile() { |
|
222 | + if (is_resource($this->_filePointer) === true) { |
|
223 | 223 | fclose($this->_filePointer); |
224 | 224 | } |
225 | 225 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | /** |
228 | 228 | * Write the EOL if file is not compressed |
229 | 229 | */ |
230 | - private function _writeEol(){ |
|
231 | - if($this->_isCompressed === false){ |
|
230 | + private function _writeEol() { |
|
231 | + if ($this->_isCompressed === false) { |
|
232 | 232 | fwrite($this->_filePointer, PHP_EOL); |
233 | 233 | } |
234 | 234 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * Write the Tabs if file is not compressed |
238 | 238 | */ |
239 | - private function _writeTabs(){ |
|
240 | - if($this->_isCompressed === false){ |
|
241 | - for($a = 0; $a < $this->_elementDeep; $a++) { |
|
239 | + private function _writeTabs() { |
|
240 | + if ($this->_isCompressed === false) { |
|
241 | + for ($a = 0; $a < $this->_elementDeep; $a++) { |
|
242 | 242 | fwrite($this->_filePointer, "\t"); |
243 | 243 | } |
244 | 244 | } |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | * @param bool $useTabs Indicates if use tabs |
252 | 252 | * @param bool $useEol Indicates if use EOL |
253 | 253 | */ |
254 | - private function _writeString($string = '', $useTabs = true, $useEol = true){ |
|
255 | - if($useTabs === true){ |
|
254 | + private function _writeString($string = '', $useTabs = true, $useEol = true) { |
|
255 | + if ($useTabs === true) { |
|
256 | 256 | $this->_writeTabs(); |
257 | 257 | } |
258 | 258 | |
259 | 259 | fwrite($this->_filePointer, $string); |
260 | 260 | |
261 | - if($useEol === true){ |
|
261 | + if ($useEol === true) { |
|
262 | 262 | $this->_writeEol(); |
263 | 263 | } |
264 | 264 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * Write file header |
268 | 268 | */ |
269 | - public function writeHeader(){ |
|
269 | + public function writeHeader() { |
|
270 | 270 | $this->_writeString($this->_fileHeader, false, true); |
271 | 271 | } |
272 | 272 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | public function closeXMLElement($tag, $expectedChildren = true) |
292 | 292 | { |
293 | 293 | $this->_elementDeep--; |
294 | - $this->_writeString('</' . $tag . '>', $expectedChildren,true); |
|
294 | + $this->_writeString('</' . $tag . '>', $expectedChildren, true); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | public function blankXMLElement($tag) |
303 | 303 | { |
304 | - $this->_writeString('<' . $tag . '/>', true,true); |
|
304 | + $this->_writeString('<' . $tag . '/>', true, true); |
|
305 | 305 | |
306 | 306 | } |
307 | 307 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @param bool $useCdata |
315 | 315 | * @param bool $forceCdata |
316 | 316 | */ |
317 | - public function saveElementWithValue($tag, $value, $decimals = 0, $useCdata = true, $forceCdata = false){ |
|
317 | + public function saveElementWithValue($tag, $value, $decimals = 0, $useCdata = true, $forceCdata = false) { |
|
318 | 318 | |
319 | 319 | /** |
320 | 320 | * Empty element |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | /** |
327 | 327 | * Non-empty element |
328 | 328 | */ |
329 | - if( $useCdata === true && (is_numeric($value) === false || $forceCdata === true) ){ |
|
330 | - if(is_numeric($value) == true){ |
|
329 | + if ($useCdata === true && (is_numeric($value) === false || $forceCdata === true)) { |
|
330 | + if (is_numeric($value) == true) { |
|
331 | 331 | $completeValue = '<![CDATA[' . round($value, $decimals) . ']]>'; |
332 | 332 | } |
333 | 333 | else { |
334 | 334 | $completeValue = '<![CDATA[' . $value . ']]>'; |
335 | 335 | } |
336 | 336 | } |
337 | - else{ |
|
338 | - if(is_numeric($value) === true) { |
|
337 | + else { |
|
338 | + if (is_numeric($value) === true) { |
|
339 | 339 | $completeValue = round($value, $decimals); |
340 | 340 | } |
341 | - else{ |
|
341 | + else { |
|
342 | 342 | $completeValue = $value; |
343 | 343 | } |
344 | 344 | } |
@@ -134,8 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | if($fileHeader === null){ |
136 | 136 | $this->_fileHeader = '<?xml version="1.0" encoding="' . $this->_encoding .'"?>'; |
137 | - } |
|
138 | - else{ |
|
137 | + } else{ |
|
139 | 138 | $this->_fileHeader = $fileHeader; |
140 | 139 | } |
141 | 140 | } |
@@ -176,8 +175,7 @@ discard block |
||
176 | 175 | */ |
177 | 176 | if($fileName === null){ |
178 | 177 | $this->setFileName(tempnam(sys_get_temp_dir(), $this->_fileNamePrefix)); |
179 | - } |
|
180 | - else{ |
|
178 | + } else{ |
|
181 | 179 | $this->setFileName($fileName); |
182 | 180 | } |
183 | 181 | |
@@ -205,8 +203,7 @@ discard block |
||
205 | 203 | public function openFile($autoAddHeader = true){ |
206 | 204 | try { |
207 | 205 | $this->_filePointer = fopen($this->_fileName, $this->_writeMode); |
208 | - } |
|
209 | - catch (\Exception $e){ |
|
206 | + } catch (\Exception $e){ |
|
210 | 207 | die('File cannot be opened: ' . $e->getMessage()); |
211 | 208 | } |
212 | 209 | |
@@ -329,16 +326,13 @@ discard block |
||
329 | 326 | if( $useCdata === true && (is_numeric($value) === false || $forceCdata === true) ){ |
330 | 327 | if(is_numeric($value) == true){ |
331 | 328 | $completeValue = '<![CDATA[' . round($value, $decimals) . ']]>'; |
332 | - } |
|
333 | - else { |
|
329 | + } else { |
|
334 | 330 | $completeValue = '<![CDATA[' . $value . ']]>'; |
335 | 331 | } |
336 | - } |
|
337 | - else{ |
|
332 | + } else{ |
|
338 | 333 | if(is_numeric($value) === true) { |
339 | 334 | $completeValue = round($value, $decimals); |
340 | - } |
|
341 | - else{ |
|
335 | + } else{ |
|
342 | 336 | $completeValue = $value; |
343 | 337 | } |
344 | 338 | } |