@@ -90,7 +90,7 @@ |
||
90 | 90 | * @param $encoding |
91 | 91 | */ |
92 | 92 | public function setEncoding($encoding){ |
93 | - $this->_encoding = $encoding; |
|
93 | + $this->_encoding = $encoding; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -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 null $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,10 +174,10 @@ 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 | |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | /** |
201 | 201 | * Open XML file |
202 | 202 | */ |
203 | - public function openFile($autoAddHeader = true){ |
|
203 | + public function openFile($autoAddHeader = true) { |
|
204 | 204 | try { |
205 | 205 | $this->_filePointer = fopen($this->_fileName, $this->_writeMode); |
206 | 206 | } |
207 | - catch (Exception $e){ |
|
207 | + catch (Exception $e) { |
|
208 | 208 | die('File cannot be opened: ' . $e->getMessage()); |
209 | 209 | } |
210 | 210 | |
211 | - if($autoAddHeader == true){ |
|
211 | + if ($autoAddHeader == true) { |
|
212 | 212 | $this->writeHeader(); |
213 | 213 | } |
214 | 214 | } |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | /** |
217 | 217 | * Close XML file if is opened |
218 | 218 | */ |
219 | - public function closeFile(){ |
|
220 | - if(is_resource($this->_filePointer) == true){ |
|
219 | + public function closeFile() { |
|
220 | + if (is_resource($this->_filePointer) == true) { |
|
221 | 221 | fclose($this->_filePointer); |
222 | 222 | } |
223 | 223 | } |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | /** |
226 | 226 | * Write the EOL if file is not compressed |
227 | 227 | */ |
228 | - private function _writeEol(){ |
|
229 | - if($this->_isCompressed == false){ |
|
228 | + private function _writeEol() { |
|
229 | + if ($this->_isCompressed == false) { |
|
230 | 230 | fwrite($this->_filePointer, PHP_EOL); |
231 | 231 | } |
232 | 232 | } |
@@ -234,9 +234,9 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * Write the Tabs if file is not compressed |
236 | 236 | */ |
237 | - private function _writeTabs(){ |
|
238 | - if($this->_isCompressed == false){ |
|
239 | - for($a = 0; $a < $this->_elementDeep; $a++) { |
|
237 | + private function _writeTabs() { |
|
238 | + if ($this->_isCompressed == false) { |
|
239 | + for ($a = 0; $a < $this->_elementDeep; $a++) { |
|
240 | 240 | fwrite($this->_filePointer, "\t"); |
241 | 241 | } |
242 | 242 | } |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | * @param bool $useTabs Indicates if use tabs |
250 | 250 | * @param bool $useEol Indicates if use EOL |
251 | 251 | */ |
252 | - private function _writeString($string = '', $useTabs = true, $useEol = true){ |
|
253 | - if($useTabs == true){ |
|
252 | + private function _writeString($string = '', $useTabs = true, $useEol = true) { |
|
253 | + if ($useTabs == true) { |
|
254 | 254 | $this->_writeTabs(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | fwrite($this->_filePointer, $string); |
258 | 258 | |
259 | - if($useEol == true){ |
|
259 | + if ($useEol == true) { |
|
260 | 260 | $this->_writeEol(); |
261 | 261 | } |
262 | 262 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | /** |
265 | 265 | * Write file header |
266 | 266 | */ |
267 | - public function writeHeader(){ |
|
267 | + public function writeHeader() { |
|
268 | 268 | $this->_writeString($this->_fileHeader, false, true); |
269 | 269 | } |
270 | 270 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | public function closeXMLElement($tag, $expectedChildren = true) |
290 | 290 | { |
291 | 291 | $this->_elementDeep--; |
292 | - $this->_writeString('</' . $tag . '>', $expectedChildren,true); |
|
292 | + $this->_writeString('</' . $tag . '>', $expectedChildren, true); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function blankXMLElement($tag) |
301 | 301 | { |
302 | - $this->_writeString('<' . $tag . '/>', true,true); |
|
302 | + $this->_writeString('<' . $tag . '/>', true, true); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param bool $useCdata |
313 | 313 | * @param bool $forceCdata |
314 | 314 | */ |
315 | - public function saveElementWithValue($tag, $value, $decimals = 0, $useCdata = true, $forceCdata = false){ |
|
315 | + public function saveElementWithValue($tag, $value, $decimals = 0, $useCdata = true, $forceCdata = false) { |
|
316 | 316 | |
317 | 317 | /** |
318 | 318 | * Empty element |
@@ -324,19 +324,19 @@ discard block |
||
324 | 324 | /** |
325 | 325 | * Non-empty element |
326 | 326 | */ |
327 | - if( $useCdata == true && (is_numeric($value) == false || $forceCdata == true) ){ |
|
328 | - if(is_numeric($value) == true){ |
|
327 | + if ($useCdata == true && (is_numeric($value) == false || $forceCdata == true)) { |
|
328 | + if (is_numeric($value) == true) { |
|
329 | 329 | $completeValue = '<![CDATA[' . number_format($value, $decimals) . ']]>'; |
330 | 330 | } |
331 | 331 | else { |
332 | 332 | $completeValue = '<![CDATA[' . $value . ']]>'; |
333 | 333 | } |
334 | 334 | } |
335 | - else{ |
|
336 | - if(is_numeric($value) == true) { |
|
335 | + else { |
|
336 | + if (is_numeric($value) == true) { |
|
337 | 337 | $completeValue = number_format($value, $decimals); |
338 | 338 | } |
339 | - else{ |
|
339 | + else { |
|
340 | 340 | $completeValue = $value; |
341 | 341 | } |
342 | 342 | } |
@@ -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 | |
@@ -203,8 +201,7 @@ discard block |
||
203 | 201 | public function openFile($autoAddHeader = true){ |
204 | 202 | try { |
205 | 203 | $this->_filePointer = fopen($this->_fileName, $this->_writeMode); |
206 | - } |
|
207 | - catch (Exception $e){ |
|
204 | + } catch (Exception $e){ |
|
208 | 205 | die('File cannot be opened: ' . $e->getMessage()); |
209 | 206 | } |
210 | 207 | |
@@ -327,16 +324,13 @@ discard block |
||
327 | 324 | if( $useCdata == true && (is_numeric($value) == false || $forceCdata == true) ){ |
328 | 325 | if(is_numeric($value) == true){ |
329 | 326 | $completeValue = '<![CDATA[' . number_format($value, $decimals) . ']]>'; |
330 | - } |
|
331 | - else { |
|
327 | + } else { |
|
332 | 328 | $completeValue = '<![CDATA[' . $value . ']]>'; |
333 | 329 | } |
334 | - } |
|
335 | - else{ |
|
330 | + } else{ |
|
336 | 331 | if(is_numeric($value) == true) { |
337 | 332 | $completeValue = number_format($value, $decimals); |
338 | - } |
|
339 | - else{ |
|
333 | + } else{ |
|
340 | 334 | $completeValue = $value; |
341 | 335 | } |
342 | 336 | } |