Passed
Push — master ( c1a518...a94b2b )
by Gaetano
08:13
created
src/Helper/Charset.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
                 if (count($this->xml_iso88591_Entities['in'])) {
92 92
                     return;
93 93
                 }
94
-                for ($i = 0; $i < 32; $i++) {
94
+                for ($i = 0; $i<32; $i++) {
95 95
                     $this->xml_iso88591_Entities["in"][] = chr($i);
96 96
                     $this->xml_iso88591_Entities["out"][] = "&#{$i};";
97 97
                 }
98 98
 
99 99
                 /// @todo to be 'print safe', should we encode as well character 127 (DEL) ?
100 100
 
101
-                for ($i = 160; $i < 256; $i++) {
101
+                for ($i = 160; $i<256; $i++) {
102 102
                     $this->xml_iso88591_Entities["in"][] = chr($i);
103 103
                     $this->xml_iso88591_Entities["out"][] = "&#{$i};";
104 104
                 }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 break;*/
127 127
 
128 128
             default:
129
-                throw new \Exception('Unsupported table: ' . $tableName);
129
+                throw new \Exception('Unsupported table: '.$tableName);
130 130
         }
131 131
     }
132 132
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             $srcEncoding = 'UTF-8';
179 179
         }
180 180
 
181
-        $conversion = strtoupper($srcEncoding . '_' . $destEncoding);
181
+        $conversion = strtoupper($srcEncoding.'_'.$destEncoding);
182 182
 
183 183
         // list ordered with (expected) most common scenarios first
184 184
         switch ($conversion) {
@@ -196,20 +196,20 @@  discard block
 block discarded – undo
196 196
                 // NB: this will choke on invalid UTF-8, going most likely beyond EOF
197 197
                 $escapedData = '';
198 198
                 // be kind to users creating string xmlrpc values out of different php types
199
-                $data = (string)$data;
199
+                $data = (string) $data;
200 200
                 $ns = strlen($data);
201
-                for ($nn = 0; $nn < $ns; $nn++) {
201
+                for ($nn = 0; $nn<$ns; $nn++) {
202 202
                     $ch = $data[$nn];
203 203
                     $ii = ord($ch);
204 204
                     // 7 bits in 1 byte: 0bbbbbbb (127)
205
-                    if ($ii < 32) {
205
+                    if ($ii<32) {
206 206
                         if ($conversion == 'UTF-8_US-ASCII') {
207 207
                             $escapedData .= sprintf('&#%d;', $ii);
208 208
                         } else {
209 209
                             $escapedData .= $ch;
210 210
                         }
211 211
                     }
212
-                    else if ($ii < 128) {
212
+                    else if ($ii<128) {
213 213
                         /// @todo shall we replace this with a (supposedly) faster str_replace?
214 214
                         /// @todo to be 'print safe', should we encode as well character 127 (DEL) ?
215 215
                         switch ($ii) {
@@ -234,25 +234,25 @@  discard block
 block discarded – undo
234 234
                     } // 11 bits in 2 bytes: 110bbbbb 10bbbbbb (2047)
235 235
                     elseif ($ii >> 5 == 6) {
236 236
                         $b1 = ($ii & 31);
237
-                        $b2 = (ord($data[$nn + 1]) & 63);
238
-                        $ii = ($b1 * 64) + $b2;
237
+                        $b2 = (ord($data[$nn+1]) & 63);
238
+                        $ii = ($b1 * 64)+$b2;
239 239
                         $escapedData .= sprintf('&#%d;', $ii);
240 240
                         $nn += 1;
241 241
                     } // 16 bits in 3 bytes: 1110bbbb 10bbbbbb 10bbbbbb
242 242
                     elseif ($ii >> 4 == 14) {
243 243
                         $b1 = ($ii & 15);
244
-                        $b2 = (ord($data[$nn + 1]) & 63);
245
-                        $b3 = (ord($data[$nn + 2]) & 63);
246
-                        $ii = ((($b1 * 64) + $b2) * 64) + $b3;
244
+                        $b2 = (ord($data[$nn+1]) & 63);
245
+                        $b3 = (ord($data[$nn+2]) & 63);
246
+                        $ii = ((($b1 * 64)+$b2) * 64)+$b3;
247 247
                         $escapedData .= sprintf('&#%d;', $ii);
248 248
                         $nn += 2;
249 249
                     } // 21 bits in 4 bytes: 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
250 250
                     elseif ($ii >> 3 == 30) {
251 251
                         $b1 = ($ii & 7);
252
-                        $b2 = (ord($data[$nn + 1]) & 63);
253
-                        $b3 = (ord($data[$nn + 2]) & 63);
254
-                        $b4 = (ord($data[$nn + 3]) & 63);
255
-                        $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
252
+                        $b2 = (ord($data[$nn+1]) & 63);
253
+                        $b3 = (ord($data[$nn+2]) & 63);
254
+                        $b4 = (ord($data[$nn+3]) & 63);
255
+                        $ii = ((((($b1 * 64)+$b2) * 64)+$b3) * 64)+$b4;
256 256
                         $escapedData .= sprintf('&#%d;', $ii);
257 257
                         $nn += 3;
258 258
                     }
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
                     // If src is UTF8, we run htmlspecialchars before converting to the target charset, as
306 306
                     // htmlspecialchars has limited charset support, but it groks utf8
307 307
                     if ($srcEncoding === 'UTF-8') {
308
-                        $data = htmlspecialchars($data,  defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8');
308
+                        $data = htmlspecialchars($data, defined('ENT_XML1') ? ENT_XML1 | ENT_QUOTES : ENT_QUOTES, 'UTF-8');
309 309
                     }
310 310
                     if ($srcEncoding !== $destEncoding) {
311 311
                         $data = mb_convert_encoding($data, str_replace('US-ASCII', 'ASCII', $destEncoding), str_replace('US-ASCII', 'ASCII', $srcEncoding));
312 312
                     }
313 313
                     if ($data === false) {
314 314
                         $escapedData = '';
315
-                        $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding via mbstring: failed...");
315
+                        $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding via mbstring: failed...");
316 316
                     } else {
317 317
                         if ($srcEncoding === 'UTF-8') {
318 318
                             $escapedData = $data;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                     }
323 323
                 } else {
324 324
                     $escapedData = '';
325
-                    $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ": Converting from $srcEncoding to $destEncoding: not supported...");
325
+                    $this->getLogger()->errorLog('XML-RPC: '.__METHOD__.": Converting from $srcEncoding to $destEncoding: not supported...");
326 326
                 }
327 327
         }
328 328
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             case 'iso88591':
378 378
                 return $this->xml_iso88591_Entities;
379 379
             default:
380
-                throw new \Exception('Unsupported charset: ' . $charset);
380
+                throw new \Exception('Unsupported charset: '.$charset);
381 381
         }
382 382
     }
383 383
 }
Please login to merge, or discard this patch.