| @@ -90,7 +90,7 @@ discard block | ||
| 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 | /** | 
| @@ -263,37 +263,37 @@ discard block | ||
| 263 | 263 | } | 
| 264 | 264 | } | 
| 265 | 265 | |
| 266 | - /** | |
| 267 | - * Determines if an array is associative. | |
| 268 | - * @param array $array | |
| 269 | - * @return bool | |
| 270 | - */ | |
| 271 | - function isAssoc(array $array) | |
| 272 | -	{ | |
| 273 | - $keys = array_keys($array); | |
| 274 | - | |
| 275 | - return array_keys($keys) !== $keys; | |
| 276 | - } | |
| 277 | - | |
| 278 | - /** | |
| 279 | - * Concatenates the attribute - value pairs into a string | |
| 280 | - * | |
| 281 | - * @param array $attr | |
| 282 | - */ | |
| 266 | + /** | |
| 267 | + * Determines if an array is associative. | |
| 268 | + * @param array $array | |
| 269 | + * @return bool | |
| 270 | + */ | |
| 271 | + function isAssoc(array $array) | |
| 272 | +    { | |
| 273 | + $keys = array_keys($array); | |
| 274 | + | |
| 275 | + return array_keys($keys) !== $keys; | |
| 276 | + } | |
| 277 | + | |
| 278 | + /** | |
| 279 | + * Concatenates the attribute - value pairs into a string | |
| 280 | + * | |
| 281 | + * @param array $attr | |
| 282 | + */ | |
| 283 | 283 | private function _getAttributes ($attr = null) | 
| 284 | 284 |      { | 
| 285 | - $str = ''; | |
| 286 | - | |
| 287 | -	      if(!is_null($attr) && is_array($attr)) { | |
| 288 | - // check if is an associative array | |
| 289 | -		        if($this->isAssoc($attr)) { | |
| 290 | -			      	  foreach ($attr as $name => $value) { | |
| 291 | -					          $str .= ' ' . $name . '="' . str_replace('"', "'", $value) . '"'; | |
| 292 | - } | |
| 293 | - } | |
| 294 | - } | |
| 295 | - | |
| 296 | - return $str; | |
| 285 | + $str = ''; | |
| 286 | + | |
| 287 | +            if(!is_null($attr) && is_array($attr)) { | |
| 288 | + // check if is an associative array | |
| 289 | +                if($this->isAssoc($attr)) { | |
| 290 | +                        foreach ($attr as $name => $value) { | |
| 291 | +                                $str .= ' ' . $name . '="' . str_replace('"', "'", $value) . '"'; | |
| 292 | + } | |
| 293 | + } | |
| 294 | + } | |
| 295 | + | |
| 296 | + return $str; | |
| 297 | 297 | } | 
| 298 | 298 | |
| 299 | 299 | /** | 
| @@ -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 | } | 
| @@ -280,13 +280,13 @@ discard block | ||
| 280 | 280 | * | 
| 281 | 281 | * @param array $attr | 
| 282 | 282 | */ | 
| 283 | - private function _getAttributes ($attr = null) | |
| 283 | + private function _getAttributes($attr = null) | |
| 284 | 284 |      { | 
| 285 | 285 | $str = ''; | 
| 286 | 286 | |
| 287 | -	      if(!is_null($attr) && is_array($attr)) { | |
| 287 | +	      if (!is_null($attr) && is_array($attr)) { | |
| 288 | 288 | // check if is an associative array | 
| 289 | -		        if($this->isAssoc($attr)) { | |
| 289 | +		        if ($this->isAssoc($attr)) { | |
| 290 | 290 |  			      	  foreach ($attr as $name => $value) { | 
| 291 | 291 |  					          $str .= ' ' . $name . '="' . str_replace('"', "'", $value) . '"'; | 
| 292 | 292 | } | 
| @@ -299,7 +299,7 @@ discard block | ||
| 299 | 299 | /** | 
| 300 | 300 | * Write file header | 
| 301 | 301 | */ | 
| 302 | -    public function writeHeader(){ | |
| 302 | +    public function writeHeader() { | |
| 303 | 303 | $this->_writeString($this->_fileHeader, false, true); | 
| 304 | 304 | } | 
| 305 | 305 | |
| @@ -325,7 +325,7 @@ discard block | ||
| 325 | 325 | public function closeXMLElement($tag, $expectedChildren = true) | 
| 326 | 326 |      { | 
| 327 | 327 | $this->_elementDeep--; | 
| 328 | -        $this->_writeString('</' . $tag . '>', $expectedChildren,true); | |
| 328 | +        $this->_writeString('</' . $tag . '>', $expectedChildren, true); | |
| 329 | 329 | } | 
| 330 | 330 | |
| 331 | 331 | /** | 
| @@ -336,7 +336,7 @@ discard block | ||
| 336 | 336 | */ | 
| 337 | 337 | public function blankXMLElement($tag, $attr = null) | 
| 338 | 338 |      { | 
| 339 | -        $this->_writeString('<' . $tag . $this->_getAttributes($attr) . '/>', true,true); | |
| 339 | +        $this->_writeString('<' . $tag . $this->_getAttributes($attr) . '/>', true, true); | |
| 340 | 340 | |
| 341 | 341 | } | 
| 342 | 342 | |
| @@ -349,7 +349,7 @@ discard block | ||
| 349 | 349 | * @param bool $useCdata | 
| 350 | 350 | * @param bool $forceCdata | 
| 351 | 351 | */ | 
| 352 | -    public function saveElementWithValue($tag, $value, $decimals = 0, $useCdata = true, $forceCdata = false){ | |
| 352 | +    public function saveElementWithValue($tag, $value, $decimals = 0, $useCdata = true, $forceCdata = false) { | |
| 353 | 353 | |
| 354 | 354 | /** | 
| 355 | 355 | * Empty element |