Passed
Branch master (c01bf5)
by Thomas
02:01
created
src/SxmlDebug.php 2 patches
Spacing   +35 added lines, -36 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
     $dump = '';
41 41
     // Note that the header is added at the end, so we can add stats
42
-    $dump .= '[' . PHP_EOL;
42
+    $dump .= '['.PHP_EOL;
43 43
 
44 44
     // SimpleXML objects can be either a single node, or (more commonly) a list of 0 or more nodes
45 45
     // I haven't found a reliable way of distinguishing between the two cases
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
         $dump .= self::dumpAddElement($item);
62 62
       }
63 63
     }
64
-    $dump .= ']' . PHP_EOL;
64
+    $dump .= ']'.PHP_EOL;
65 65
 
66 66
     // Add on the header line, with the total number of items output
67
-    return self::getHeaderLine($item_index) . $dump;
67
+    return self::getHeaderLine($item_index).$dump;
68 68
   }
69 69
 
70 70
   /**
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
     // To what namespace does this attribute belong? Returns array( alias => URI )
78 78
     $ns = $item->getNamespaces(FALSE);
79 79
     if ($ns) {
80
-      $dump .= self::INDENT . self::INDENT . 'Namespace: \'' . reset($ns) .
81
-               '\'' .
80
+      $dump .= self::INDENT.self::INDENT.'Namespace: \''.reset($ns).
81
+               '\''.
82 82
                PHP_EOL;
83 83
       if (key($ns) == '') {
84
-        $dump .= self::INDENT . self::INDENT . '(Default Namespace)' . PHP_EOL;
84
+        $dump .= self::INDENT.self::INDENT.'(Default Namespace)'.PHP_EOL;
85 85
       } else {
86
-        $dump .= self::INDENT . self::INDENT . 'Namespace Alias: \'' .
87
-                 key($ns) .
88
-                 '\'' .
86
+        $dump .= self::INDENT.self::INDENT.'Namespace Alias: \''.
87
+                 key($ns).
88
+                 '\''.
89 89
                  PHP_EOL;
90 90
       }
91 91
     }
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
                                       $data,
105 105
                                       $indent = 1,
106 106
                                       $backtick = TRUE): string {
107
-    return str_repeat(self::INDENT, $indent) . $title . ': ' .
108
-           ($backtick ? '\'' : '') . $data .
109
-           ($backtick ? '\'' : '') . PHP_EOL;
107
+    return str_repeat(self::INDENT, $indent).$title.': '.
108
+           ($backtick ? '\'' : '').$data.
109
+           ($backtick ? '\'' : '').PHP_EOL;
110 110
   }
111 111
 
112 112
   /**
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
    */
116 116
   private static function dumpAddAttribute(\SimpleXMLElement $item): string {
117 117
 
118
-    $dump = self::INDENT . 'Attribute {' . PHP_EOL;
118
+    $dump = self::INDENT.'Attribute {'.PHP_EOL;
119 119
 
120 120
     $dump .= self::dumpAddNamespace($item);
121 121
 
122 122
     $dump .= self::dumpGetLine('Name', $item->getName(), 2);
123 123
     $dump .= self::dumpGetLine('Value', (string) $item, 2);
124 124
 
125
-    $dump .= self::INDENT . '}' . PHP_EOL;
125
+    $dump .= self::INDENT.'}'.PHP_EOL;
126 126
     return $dump;
127 127
 
128 128
   }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
    */
134 134
   private static function dumpAddElement(\SimpleXMLElement $item): string {
135 135
 
136
-    $dump = self::INDENT . 'Element {' . PHP_EOL;
136
+    $dump = self::INDENT.'Element {'.PHP_EOL;
137 137
 
138 138
     $dump .= self::dumpAddNamespace($item);
139 139
 
@@ -176,10 +176,9 @@  discard block
 block discarded – undo
176 176
         continue;
177 177
       }
178 178
 
179
-      $ns_label = (($ns_alias === '') ? 'Default Namespace' :
180
-        "Namespace $ns_alias");
179
+      $ns_label = (($ns_alias === '') ? 'Default Namespace' : "Namespace $ns_alias");
181 180
 
182
-      $dump .= self::INDENT . self::INDENT . 'Content in ' . $ns_label .
181
+      $dump .= self::INDENT.self::INDENT.'Content in '.$ns_label.
183 182
                PHP_EOL;
184 183
 
185 184
       if (NULL !== $ns_uri) {
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
                                  FALSE);
200 199
     }
201 200
 
202
-    return $dump . self::INDENT . '}' . PHP_EOL;
201
+    return $dump.self::INDENT.'}'.PHP_EOL;
203 202
   }
204 203
 
205 204
   /**
@@ -228,7 +227,7 @@  discard block
 block discarded – undo
228 227
     $childrenString = count($children);
229 228
     // Don't output a trailing " - " if there are no children
230 229
     if (count($children) > 0) {
231
-      $childrenString .= ' - ' . implode(', ', $child_name_output);
230
+      $childrenString .= ' - '.implode(', ', $child_name_output);
232 231
     }
233 232
     return $childrenString;
234 233
   }
@@ -241,14 +240,14 @@  discard block
 block discarded – undo
241 240
 // Attributes can't be duplicated, but I'm going to put them in alphabetical order
242 241
     $attribute_names = [];
243 242
     foreach ($attributes as $sx_attribute) {
244
-      $attribute_names[] = "'" . $sx_attribute->getName() . "'";
243
+      $attribute_names[] = "'".$sx_attribute->getName()."'";
245 244
     }
246 245
     ksort($attribute_names);
247 246
 
248 247
     $attString = count($attributes);
249 248
     // Don't output a trailing " - " if there are no attributes
250 249
     if (count($attributes) > 0) {
251
-      $attString .= ' - ' . implode(', ', $attribute_names);
250
+      $attString .= ' - '.implode(', ', $attribute_names);
252 251
     }
253 252
     return $attString;
254 253
   }
@@ -259,8 +258,8 @@  discard block
 block discarded – undo
259 258
    */
260 259
   private static function getHeaderLine($index): string {
261 260
 
262
-    return 'SimpleXML object (' . $index . ' item' .
263
-           ($index > 1 ? 's' : '') . ')' . PHP_EOL;
261
+    return 'SimpleXML object ('.$index.' item'.
262
+           ($index > 1 ? 's' : '').')'.PHP_EOL;
264 263
   }
265 264
 
266 265
   /**
@@ -304,9 +303,9 @@  discard block
 block discarded – undo
304 303
         // To what namespace does this attribute belong? Returns array( alias => URI )
305 304
         $ns = $root_item->getNamespaces(FALSE);
306 305
         if (key($ns)) {
307
-          $dump .= key($ns) . ':';
306
+          $dump .= key($ns).':';
308 307
         }
309
-        $dump .= $root_item->getName() . '="' . (string) $root_item . '"' .
308
+        $dump .= $root_item->getName().'="'.(string) $root_item.'"'.
310 309
                  PHP_EOL;
311 310
       } else {
312 311
         // Display the root node as a numeric key reference, plus a hint as to its tag name
@@ -315,11 +314,11 @@  discard block
 block discarded – undo
315 314
         // To what namespace does this attribute belong? Returns array( alias => URI )
316 315
         $ns = $root_item->getNamespaces(FALSE);
317 316
         if (key($ns)) {
318
-          $root_node_name = key($ns) . ':' . $root_item->getName();
317
+          $root_node_name = key($ns).':'.$root_item->getName();
319 318
         } else {
320 319
           $root_node_name = $root_item->getName();
321 320
         }
322
-        $dump .= "[$root_item_index] // <$root_node_name>" . PHP_EOL;
321
+        $dump .= "[$root_item_index] // <$root_node_name>".PHP_EOL;
323 322
 
324 323
         // This function is effectively recursing depth-first through the tree,
325 324
         // but this is managed manually using a stack rather than actual recursion
@@ -335,7 +334,7 @@  discard block
 block discarded – undo
335 334
     }
336 335
 
337 336
     // Add on the header line, with the total number of items output
338
-    $dump = self::getHeaderLine($root_item_index) . $dump;
337
+    $dump = self::getHeaderLine($root_item_index).$dump;
339 338
 
340 339
     return $dump;
341 340
 
@@ -358,7 +357,7 @@  discard block
 block discarded – undo
358 357
       str_repeat(SxmlDebug::INDENT, $depth)
359 358
       . '(string) '
360 359
       . "'$string_extract'"
361
-      . ' (' . strlen($stringContent) . ' chars)'
360
+      . ' ('.strlen($stringContent).' chars)'
362 361
       . PHP_EOL : '';
363 362
 
364 363
   }
@@ -405,7 +404,7 @@  discard block
 block discarded – undo
405 404
     if (count($attributes) > 0) {
406 405
       if (!$isCurrentNamespace) {
407 406
         $dump .= str_repeat(self::INDENT, $depth)
408
-                 . "->attributes('$nsAlias', true)" . PHP_EOL;
407
+                 . "->attributes('$nsAlias', true)".PHP_EOL;
409 408
       }
410 409
 
411 410
       foreach ($attributes as $sx_attribute) {
@@ -414,14 +413,14 @@  discard block
 block discarded – undo
414 413
           // In current namespace
415 414
           // e.g. ['attribName']
416 415
           $dump .= str_repeat(self::INDENT, $depth)
417
-                   . "['" . $sx_attribute->getName() . "']"
416
+                   . "['".$sx_attribute->getName()."']"
418 417
                    . PHP_EOL;
419 418
           $string_display_depth = $depth + 1;
420 419
         } else {
421 420
           // After a call to ->attributes()
422 421
           // e.g. ->attribName
423 422
           $dump .= str_repeat(self::INDENT, $depth + 1)
424
-                   . '->' . $sx_attribute->getName()
423
+                   . '->'.$sx_attribute->getName()
425 424
                    . PHP_EOL;
426 425
           $string_display_depth = $depth + 2;
427 426
         }
@@ -456,7 +455,7 @@  discard block
 block discarded – undo
456 455
         $display_depth = $depth;
457 456
       } else {
458 457
         $dump .= str_repeat(self::INDENT, $depth)
459
-                 . "->children('$nsAlias', true)" . PHP_EOL;
458
+                 . "->children('$nsAlias', true)".PHP_EOL;
460 459
         $display_depth = $depth + 1;
461 460
       }
462 461
 
@@ -474,8 +473,8 @@  discard block
 block discarded – undo
474 473
 
475 474
         // e.g. ->Foo[0]
476 475
         $dump .= str_repeat(self::INDENT, $display_depth)
477
-                 . '->' . $sx_child->getName()
478
-                 . '[' . ($child_names[$child_node_name] - 1) . ']'
476
+                 . '->'.$sx_child->getName()
477
+                 . '['.($child_names[$child_node_name] - 1).']'
479 478
                  . PHP_EOL;
480 479
 
481 480
         $dump .= self::recursivelyProcessNode(
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
     $ns = $item->getNamespaces(FALSE);
79 79
     if (!empty($ns)) {
80 80
       $dump .= self::INDENT . self::INDENT . 'Namespace: \'' . reset($ns) .
81
-               '\'' .
82
-               PHP_EOL;
81
+                '\'' .
82
+                PHP_EOL;
83 83
       if (key($ns) == '') {
84 84
         $dump .= self::INDENT . self::INDENT . '(Default Namespace)' . PHP_EOL;
85 85
       } else {
86 86
         $dump .= self::INDENT . self::INDENT . 'Namespace Alias: \'' .
87
-                 key($ns) .
88
-                 '\'' .
89
-                 PHP_EOL;
87
+                  key($ns) .
88
+                  '\'' .
89
+                  PHP_EOL;
90 90
       }
91 91
     }
92 92
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
                                       $indent = 1,
106 106
                                       $backtick = TRUE): string {
107 107
     return str_repeat(self::INDENT, $indent) . $title . ': ' .
108
-           ($backtick ? '\'' : '') . $data .
109
-           ($backtick ? '\'' : '') . PHP_EOL;
108
+            ($backtick ? '\'' : '') . $data .
109
+            ($backtick ? '\'' : '') . PHP_EOL;
110 110
   }
111 111
 
112 112
   /**
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         "Namespace $ns_alias");
181 181
 
182 182
       $dump .= self::INDENT . self::INDENT . 'Content in ' . $ns_label .
183
-               PHP_EOL;
183
+                PHP_EOL;
184 184
 
185 185
       if (NULL !== $ns_uri) {
186 186
         $dump .= self::dumpGetLine('Namespace URI', $ns_uri, 3);
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 
189 189
 
190 190
       $dump .= self::dumpGetLine('Children',
191
-                                 self::dumpGetChildDetails($children),
192
-                                 3,
193
-                                 FALSE);
191
+                                  self::dumpGetChildDetails($children),
192
+                                  3,
193
+                                  FALSE);
194 194
 
195 195
 
196 196
       $dump .= self::dumpGetLine('Attributes',
197
-                                 self::dumpGetAttributeDetails($attributes),
198
-                                 3,
199
-                                 FALSE);
197
+                                  self::dumpGetAttributeDetails($attributes),
198
+                                  3,
199
+                                  FALSE);
200 200
     }
201 201
 
202 202
     return $dump . self::INDENT . '}' . PHP_EOL;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
   private static function getHeaderLine($index): string {
261 261
 
262 262
     return 'SimpleXML object (' . $index . ' item' .
263
-           ($index > 1 ? 's' : '') . ')' . PHP_EOL;
263
+            ($index > 1 ? 's' : '') . ')' . PHP_EOL;
264 264
   }
265 265
 
266 266
   /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
           $dump .= key($ns) . ':';
304 304
         }
305 305
         $dump .= $root_item->getName() . '="' . (string) $root_item . '"' .
306
-                 PHP_EOL;
306
+                  PHP_EOL;
307 307
       } else {
308 308
         // Display the root node as a numeric key reference, plus a hint as to its tag name
309 309
         // e.g. '[42] // <Answer>'
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
    * @return string
345 345
    */
346 346
   private static function treeGetStringExtract(string $stringContent,
347
-                                               $depth): string {
347
+                                                $depth): string {
348 348
     $string_extract = preg_replace('/\s+/', ' ', trim($stringContent));
349 349
     if (strlen($string_extract) > SxmlDebug::EXTRACT_SIZE) {
350 350
       $string_extract = substr($string_extract, 0, SxmlDebug::EXTRACT_SIZE)
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
     if (count($attributes) > 0) {
402 402
       if (!$isCurrentNamespace) {
403 403
         $dump .= str_repeat(self::INDENT, $depth)
404
-                 . "->attributes('$nsAlias', true)" . PHP_EOL;
404
+                  . "->attributes('$nsAlias', true)" . PHP_EOL;
405 405
       }
406 406
 
407 407
       foreach ($attributes as $sx_attribute) {
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
           // In current namespace
411 411
           // e.g. ['attribName']
412 412
           $dump .= str_repeat(self::INDENT, $depth)
413
-                   . "['" . $sx_attribute->getName() . "']"
414
-                   . PHP_EOL;
413
+                    . "['" . $sx_attribute->getName() . "']"
414
+                    . PHP_EOL;
415 415
           $string_display_depth = $depth + 1;
416 416
         } else {
417 417
           // After a call to ->attributes()
418 418
           // e.g. ->attribName
419 419
           $dump .= str_repeat(self::INDENT, $depth + 1)
420
-                   . '->' . $sx_attribute->getName()
421
-                   . PHP_EOL;
420
+                    . '->' . $sx_attribute->getName()
421
+                    . PHP_EOL;
422 422
           $string_display_depth = $depth + 2;
423 423
         }
424 424
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         $display_depth = $depth;
453 453
       } else {
454 454
         $dump .= str_repeat(self::INDENT, $depth)
455
-                 . "->children('$nsAlias', true)" . PHP_EOL;
455
+                  . "->children('$nsAlias', true)" . PHP_EOL;
456 456
         $display_depth = $depth + 1;
457 457
       }
458 458
 
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 
471 471
         // e.g. ->Foo[0]
472 472
         $dump .= str_repeat(self::INDENT, $display_depth)
473
-                 . '->' . $sx_child->getName()
474
-                 . '[' . ($child_names[$child_node_name] - 1) . ']'
475
-                 . PHP_EOL;
473
+                  . '->' . $sx_child->getName()
474
+                  . '[' . ($child_names[$child_node_name] - 1) . ']'
475
+                  . PHP_EOL;
476 476
 
477 477
         $dump .= self::recursivelyProcessNode(
478 478
           $sx_child,
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
    * @return string
492 492
    */
493 493
   private static function recursivelyProcessNode(\SimpleXMLElement $item,
494
-                                                 $depth,
495
-                                                 $include_string_content): string {
494
+                                                  $depth,
495
+                                                  $include_string_content): string {
496 496
 
497 497
     $dump = '';
498 498
 
@@ -509,15 +509,15 @@  discard block
 block discarded – undo
509 509
       $is_current_namespace = ($ns_uri === reset($itemNs));
510 510
 
511 511
       $dump .= self::treeProcessAttributes($item->attributes($ns_alias, TRUE),
512
-                                           $ns_alias,
513
-                                           $depth,
514
-                                           $is_current_namespace,
515
-                                           $include_string_content);
512
+                                            $ns_alias,
513
+                                            $depth,
514
+                                            $is_current_namespace,
515
+                                            $include_string_content);
516 516
       $dump .= self::treeProcessChildren($item->children($ns_alias, TRUE),
517
-                                         $ns_alias,
518
-                                         $depth,
519
-                                         $is_current_namespace,
520
-                                         $include_string_content);
517
+                                          $ns_alias,
518
+                                          $depth,
519
+                                          $is_current_namespace,
520
+                                          $include_string_content);
521 521
     }
522 522
 
523 523
     return $dump;
Please login to merge, or discard this patch.