Completed
Branch master (ae8dd7)
by Daniele
07:55
created
specs/FluidXml.php 1 patch
Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
                 \assert($actual === $expected, __($actual, $expected));
26 26
 
27 27
                 $options = [ 'root'       => 'root',
28
-                             'version'    => '1.2',
29
-                             'encoding'   => 'UTF-16',
30
-                             'stylesheet' => 'stylesheet.xsl' ];
28
+                                'version'    => '1.2',
29
+                                'encoding'   => 'UTF-16',
30
+                                'stylesheet' => 'stylesheet.xsl' ];
31 31
 
32 32
                 $xml   = new FluidXml($options);
33 33
                 $alias = fluidxml($options);
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 describe('FluidXml', function() {
154 154
         describe(':load', function() {
155 155
                 $doc = "<root>\n"
156
-                     . "  <parent>content</parent>\n"
157
-                     . "</root>";
156
+                        . "  <parent>content</parent>\n"
157
+                        . "</root>";
158 158
                 $dom = new \DOMDocument();
159 159
                 $dom->loadXML($doc);
160 160
 
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
                         \assert($actual === $expected, __($actual, $expected));
266 266
 
267 267
                         $options = [ 'root'       => 'root',
268
-                                     'version'    => '1.2',
269
-                                     'encoding'   => 'UTF-16',
270
-                                     'stylesheet' => 'stylesheet.xsl' ];
268
+                                        'version'    => '1.2',
269
+                                        'encoding'   => 'UTF-16',
270
+                                        'stylesheet' => 'stylesheet.xsl' ];
271 271
 
272 272
                         $xml   = new FluidXml($options);
273 273
                         eval('$alias = \FluidXml\FluidXml::new($options);');
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 
282 282
         describe('()', function() {
283 283
                 $stylesheet = "<?xml-stylesheet type=\"text/xsl\" "
284
-                                              . "encoding=\"UTF-8\" "
285
-                                              . "indent=\"yes\" "
286
-                                              . "href=\"http://servo-php.org/fluidxml\"?>";
284
+                                                . "encoding=\"UTF-8\" "
285
+                                                . "indent=\"yes\" "
286
+                                                . "href=\"http://servo-php.org/fluidxml\"?>";
287 287
 
288 288
                 it('should be an UTF-8 XML-1.0 document with one default root element', function() {
289 289
                         $xml = new FluidXml();
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                         $xml = new FluidXml(['stylesheet' => 'http://servo-php.org/fluidxml']);
316 316
 
317 317
                         $expected = $stylesheet . "\n"
318
-                                  . "<doc/>";
318
+                                        . "<doc/>";
319 319
                         assert_equal_xml($xml, $expected);
320 320
                 });
321 321
 
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
                         $x_ns  = new FluidNamespace('x', 'x.com');
368 368
                         $xx_ns = fluidns('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT);
369 369
                         $nss = $xml->namespace($x_ns)
370
-                                   ->namespace($xx_ns)
371
-                                   ->namespaces();
370
+                                        ->namespace($xx_ns)
371
+                                        ->namespaces();
372 372
 
373 373
                         $actual   = $nss[$x_ns->id()];
374 374
                         $expected = $x_ns;
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
                         $xml = new FluidXml();
384 384
 
385 385
                         $nss = $xml->namespace('x', 'x.com')
386
-                                   ->namespace('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT)
387
-                                   ->namespaces();
386
+                                        ->namespace('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT)
387
+                                        ->namespaces();
388 388
 
389 389
                         $actual   = $nss['x']->uri();
390 390
                         $expected = 'x.com';
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
                         $xx_ns = fluidns('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT);
410 410
 
411 411
                         $nss = $xml->namespace($x_ns, $xx_ns)
412
-                                   ->namespaces();
412
+                                        ->namespaces();
413 413
 
414 414
                         $actual   = $nss[$x_ns->id()];
415 415
                         $expected = $x_ns;
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
                         $xx_ns = fluidns('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT);
427 427
 
428 428
                         $nss = $xml->namespace([ $x_ns, $xx_ns ])
429
-                                   ->namespaces();
429
+                                        ->namespaces();
430 430
 
431 431
                         $actual   = $nss[$x_ns->id()];
432 432
                         $expected = $x_ns;
@@ -467,60 +467,60 @@  discard block
 block discarded – undo
467 467
                 it('should accept an array of queries', function() {
468 468
                         $xml = new FluidXml();
469 469
                         $xml->appendChild('html', true)
470
-                            ->appendChild(['head','body']);
470
+                                ->appendChild(['head','body']);
471 471
                         $xml->query(['//html', '//head', '//body'])
472
-                            ->setAttribute('lang', 'en');
472
+                                ->setAttribute('lang', 'en');
473 473
 
474 474
                         $expected = "<doc>\n"
475
-                                  . "  <html lang=\"en\">\n"
476
-                                  . "    <head lang=\"en\"/>\n"
477
-                                  . "    <body lang=\"en\"/>\n"
478
-                                  . "  </html>\n"
479
-                                  . "</doc>";
475
+                                        . "  <html lang=\"en\">\n"
476
+                                        . "    <head lang=\"en\"/>\n"
477
+                                        . "    <body lang=\"en\"/>\n"
478
+                                        . "  </html>\n"
479
+                                        . "</doc>";
480 480
                         assert_equal_xml($xml, $expected);
481 481
 
482 482
                         $xml = new FluidXml();
483 483
                         $xml->appendChild('html', true)
484
-                            ->appendChild(['head','body'])
485
-                            ->query(['.', 'head', 'body'])
486
-                            ->setAttribute('lang', 'en');
484
+                                ->appendChild(['head','body'])
485
+                                ->query(['.', 'head', 'body'])
486
+                                ->setAttribute('lang', 'en');
487 487
 
488 488
                         $expected = "<doc>\n"
489
-                                  . "  <html lang=\"en\">\n"
490
-                                  . "    <head lang=\"en\"/>\n"
491
-                                  . "    <body lang=\"en\"/>\n"
492
-                                  . "  </html>\n"
493
-                                  . "</doc>";
489
+                                        . "  <html lang=\"en\">\n"
490
+                                        . "    <head lang=\"en\"/>\n"
491
+                                        . "    <body lang=\"en\"/>\n"
492
+                                        . "  </html>\n"
493
+                                        . "</doc>";
494 494
                         assert_equal_xml($xml, $expected);
495 495
                 });
496 496
 
497 497
                 it('should accept variable queries arguments', function() {
498 498
                         $xml = new FluidXml();
499 499
                         $xml->appendChild('html', true)
500
-                            ->appendChild(['head','body']);
500
+                                ->appendChild(['head','body']);
501 501
                         $xml->query('//html', '//head', '//body')
502
-                            ->setAttribute('lang', 'en');
502
+                                ->setAttribute('lang', 'en');
503 503
 
504 504
                         $expected = "<doc>\n"
505
-                                  . "  <html lang=\"en\">\n"
506
-                                  . "    <head lang=\"en\"/>\n"
507
-                                  . "    <body lang=\"en\"/>\n"
508
-                                  . "  </html>\n"
509
-                                  . "</doc>";
505
+                                        . "  <html lang=\"en\">\n"
506
+                                        . "    <head lang=\"en\"/>\n"
507
+                                        . "    <body lang=\"en\"/>\n"
508
+                                        . "  </html>\n"
509
+                                        . "</doc>";
510 510
                         assert_equal_xml($xml, $expected);
511 511
 
512 512
                         $xml = new FluidXml();
513 513
                         $xml->appendChild('html', true)
514
-                            ->appendChild(['head','body'])
515
-                            ->query('.', 'head', 'body')
516
-                            ->setAttribute('lang', 'en');
514
+                                ->appendChild(['head','body'])
515
+                                ->query('.', 'head', 'body')
516
+                                ->setAttribute('lang', 'en');
517 517
 
518 518
                         $expected = "<doc>\n"
519
-                                  . "  <html lang=\"en\">\n"
520
-                                  . "    <head lang=\"en\"/>\n"
521
-                                  . "    <body lang=\"en\"/>\n"
522
-                                  . "  </html>\n"
523
-                                  . "</doc>";
519
+                                        . "  <html lang=\"en\">\n"
520
+                                        . "    <head lang=\"en\"/>\n"
521
+                                        . "    <body lang=\"en\"/>\n"
522
+                                        . "  </html>\n"
523
+                                        . "</doc>";
524 524
                         assert_equal_xml($xml, $expected);
525 525
                 });
526 526
 
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
                         // XPATH: //child/subchild //child
549 549
                         $xml = new FluidXml();
550 550
                         $xml->appendChild('html', true)
551
-                            ->appendChild(['head','body']);
551
+                                ->appendChild(['head','body']);
552 552
                         $cx = $xml->query('/doc/html/body')
553
-                                  ->appendChild('h1')
554
-                                  ->query('/doc/html/head');
553
+                                        ->appendChild('h1')
554
+                                        ->query('/doc/html/head');
555 555
 
556 556
                         $actual   = $cx[0]->nodeName;
557 557
                         $expected = 'head';
@@ -562,21 +562,21 @@  discard block
 block discarded – undo
562 562
                         // XPATH: //child/subchild ../..
563 563
                         $xml = new FluidXml();
564 564
                         $xml->appendChild('html', true)
565
-                            ->appendChild(['head','body'], true)
566
-                            ->query('../body')
567
-                            ->appendChild('h1')
568
-                            ->query('../..')
569
-                            ->appendChild('extra');
565
+                                ->appendChild(['head','body'], true)
566
+                                ->query('../body')
567
+                                ->appendChild('h1')
568
+                                ->query('../..')
569
+                                ->appendChild('extra');
570 570
 
571 571
                         $expected = "<doc>\n"
572
-                                  . "  <html>\n"
573
-                                  . "    <head/>\n"
574
-                                  . "    <body>\n"
575
-                                  . "      <h1/>\n"
576
-                                  . "    </body>\n"
577
-                                  . "  </html>\n"
578
-                                  . "  <extra/>\n"
579
-                                  . "</doc>";
572
+                                        . "  <html>\n"
573
+                                        . "    <head/>\n"
574
+                                        . "    <body>\n"
575
+                                        . "      <h1/>\n"
576
+                                        . "    </body>\n"
577
+                                        . "  </html>\n"
578
+                                        . "  <extra/>\n"
579
+                                        . "</doc>";
580 580
                         assert_equal_xml($xml, $expected);
581 581
                 });
582 582
 
@@ -588,12 +588,12 @@  discard block
 block discarded – undo
588 588
                         $xml->namespace($x_ns, $xx_ns);
589 589
 
590 590
                         $xml->appendChild('x:a',  true)
591
-                            ->appendChild('x:b',  true)
592
-                            ->appendChild('xx:c', true)
593
-                            ->appendChild('xx:d', true)
594
-                            ->appendChild('e',    true)
595
-                            ->appendChild('x:f',  true)
596
-                            ->appendChild('g');
591
+                                ->appendChild('x:b',  true)
592
+                                ->appendChild('xx:c', true)
593
+                                ->appendChild('xx:d', true)
594
+                                ->appendChild('e',    true)
595
+                                ->appendChild('x:f',  true)
596
+                                ->appendChild('g');
597 597
 
598 598
                         $r = $xml->query('/doc/a');
599 599
 
@@ -674,12 +674,12 @@  discard block
 block discarded – undo
674 674
                         });
675 675
 
676 676
                         $xml->appendChild('child1')
677
-                            ->appendChild('child2');
677
+                                ->appendChild('child2');
678 678
 
679 679
                         $nodes = [];
680 680
                         $index = 0;
681 681
                         $xml->query('/doc/*')
682
-                            ->each(function($cx, $n, $i) use (&$nodes, &$index) {
682
+                                ->each(function($cx, $n, $i) use (&$nodes, &$index) {
683 683
                                 $cx->setText($n->nodeName);
684 684
                                 $nodes[] = $n;
685 685
 
@@ -695,9 +695,9 @@  discard block
 block discarded – undo
695 695
                         \assert($actual === $expected, __($actual, $expected));
696 696
 
697 697
                         $expected = "<doc>\n"
698
-                                  . "  <child1>child1</child1>\n"
699
-                                  . "  <child2>child2</child2>\n"
700
-                                  . "</doc>";
698
+                                        . "  <child1>child1</child1>\n"
699
+                                        . "  <child2>child2</child2>\n"
700
+                                        . "</doc>";
701 701
                         assert_equal_xml($xml, $expected);
702 702
                 });
703 703
         });
@@ -713,13 +713,13 @@  discard block
 block discarded – undo
713 713
 
714 714
                         $xml->times(2)
715 715
                                 ->add('child')
716
-                            ->add('lastchild');
716
+                                ->add('lastchild');
717 717
 
718 718
                         $expected = "<doc>\n"
719
-                                  . "  <child/>\n"
720
-                                  . "  <child/>\n"
721
-                                  . "  <lastchild/>\n"
722
-                                  . "</doc>";
719
+                                        . "  <child/>\n"
720
+                                        . "  <child/>\n"
721
+                                        . "  <lastchild/>\n"
722
+                                        . "</doc>";
723 723
                         assert_equal_xml($xml, $expected);
724 724
                 });
725 725
 
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
                                         ->add('subchild');
732 732
 
733 733
                         $expected = "<doc>\n"
734
-                                  . "  <child>\n"
735
-                                  . "    <subchild/>\n"
736
-                                  . "  </child>\n"
737
-                                  . "  <child>\n"
738
-                                  . "    <subchild/>\n"
739
-                                  . "  </child>\n"
740
-                                  . "</doc>";
734
+                                        . "  <child>\n"
735
+                                        . "    <subchild/>\n"
736
+                                        . "  </child>\n"
737
+                                        . "  <child>\n"
738
+                                        . "    <subchild/>\n"
739
+                                        . "  </child>\n"
740
+                                        . "</doc>";
741 741
                         assert_equal_xml($xml, $expected);
742 742
                 });
743 743
 
@@ -752,14 +752,14 @@  discard block
 block discarded – undo
752 752
                                 ->add('lastchild');
753 753
 
754 754
                         $expected = "<doc>\n"
755
-                                  . "  <parent>\n"
756
-                                  . "    <child0/>\n"
757
-                                  . "    <sep/>\n"
758
-                                  . "    <child1/>\n"
759
-                                  . "    <sep/>\n"
760
-                                  . "    <lastchild/>\n"
761
-                                  . "  </parent>\n"
762
-                                  . "</doc>";
755
+                                        . "  <parent>\n"
756
+                                        . "    <child0/>\n"
757
+                                        . "    <sep/>\n"
758
+                                        . "    <child1/>\n"
759
+                                        . "    <sep/>\n"
760
+                                        . "    <lastchild/>\n"
761
+                                        . "  </parent>\n"
762
+                                        . "</doc>";
763 763
                         assert_equal_xml($xml, $expected);
764 764
                 });
765 765
         });
@@ -772,46 +772,46 @@  discard block
 block discarded – undo
772 772
                 it('should add a child', function() {
773 773
                         $xml = new FluidXml();
774 774
                         $xml->appendChild('child1')
775
-                            ->appendChild('child2')
776
-                            ->appendChild('parent', true)
777
-                            ->appendChild('child3')
778
-                            ->appendChild('child4');
775
+                                ->appendChild('child2')
776
+                                ->appendChild('parent', true)
777
+                                ->appendChild('child3')
778
+                                ->appendChild('child4');
779 779
 
780 780
                         $expected = "<doc>\n"
781
-                                  . "  <child1/>\n"
782
-                                  . "  <child2/>\n"
783
-                                  . "  <parent>\n"
784
-                                  . "    <child3/>\n"
785
-                                  . "    <child4/>\n"
786
-                                  . "  </parent>\n"
787
-                                  . "</doc>";
781
+                                        . "  <child1/>\n"
782
+                                        . "  <child2/>\n"
783
+                                        . "  <parent>\n"
784
+                                        . "    <child3/>\n"
785
+                                        . "    <child4/>\n"
786
+                                        . "  </parent>\n"
787
+                                        . "</doc>";
788 788
                         assert_equal_xml($xml, $expected);
789 789
                 });
790 790
 
791 791
                 it('should add many children', function() {
792 792
                         $xml = new FluidXml();
793 793
                         $xml->appendChild(['child1', 'child2'])
794
-                            ->appendChild('parent', true)
795
-                            ->appendChild(['child3', 'child4']);
794
+                                ->appendChild('parent', true)
795
+                                ->appendChild(['child3', 'child4']);
796 796
 
797 797
                         $expected = "<doc>\n"
798
-                                  . "  <child1/>\n"
799
-                                  . "  <child2/>\n"
800
-                                  . "  <parent>\n"
801
-                                  . "    <child3/>\n"
802
-                                  . "    <child4/>\n"
803
-                                  . "  </parent>\n"
804
-                                  . "</doc>";
798
+                                        . "  <child1/>\n"
799
+                                        . "  <child2/>\n"
800
+                                        . "  <parent>\n"
801
+                                        . "    <child3/>\n"
802
+                                        . "    <child4/>\n"
803
+                                        . "  </parent>\n"
804
+                                        . "</doc>";
805 805
                         assert_equal_xml($xml, $expected);
806 806
                 });
807 807
 
808 808
                 it('should add many children recursively', function() {
809 809
                         $xml = new FluidXml();
810 810
                         $xml->appendChild(['child1'=>['child11'=>['child111', 'child112'=>'value112'], 'child12'=>'value12'],
811
-                                           'child2'=>['child21', 'child22'=>['child221', 'child222']]])
812
-                            ->appendChild('parent', true)
813
-                            ->appendChild(['child3'=>['child31'=>['child311', 'child312'=>'value312'], 'child32'=>'value32'],
814
-                                           'child4'=>['child41', 'child42'=>['child421', 'child422']]]);
811
+                                                'child2'=>['child21', 'child22'=>['child221', 'child222']]])
812
+                                ->appendChild('parent', true)
813
+                                ->appendChild(['child3'=>['child31'=>['child311', 'child312'=>'value312'], 'child32'=>'value32'],
814
+                                                'child4'=>['child41', 'child42'=>['child421', 'child422']]]);
815 815
 
816 816
                         $expected = <<<EOF
817 817
 <doc>
@@ -854,106 +854,106 @@  discard block
 block discarded – undo
854 854
                 it('should add a child with a value', function() {
855 855
                         $xml = new FluidXml();
856 856
                         $xml->appendChild(['child1' => 'value1'])
857
-                            ->appendChild('child2', 'value2')
858
-                            ->appendChild('parent', true)
859
-                            ->appendChild(['child3' => 'value3'])
860
-                            ->appendChild('child4', 'value4');
857
+                                ->appendChild('child2', 'value2')
858
+                                ->appendChild('parent', true)
859
+                                ->appendChild(['child3' => 'value3'])
860
+                                ->appendChild('child4', 'value4');
861 861
 
862 862
                         $expected = "<doc>\n"
863
-                                  . "  <child1>value1</child1>\n"
864
-                                  . "  <child2>value2</child2>\n"
865
-                                  . "  <parent>\n"
866
-                                  . "    <child3>value3</child3>\n"
867
-                                  . "    <child4>value4</child4>\n"
868
-                                  . "  </parent>\n"
869
-                                  . "</doc>";
863
+                                        . "  <child1>value1</child1>\n"
864
+                                        . "  <child2>value2</child2>\n"
865
+                                        . "  <parent>\n"
866
+                                        . "    <child3>value3</child3>\n"
867
+                                        . "    <child4>value4</child4>\n"
868
+                                        . "  </parent>\n"
869
+                                        . "</doc>";
870 870
                         assert_equal_xml($xml, $expected);
871 871
                 });
872 872
 
873 873
                 it('should add many children with a value', function() {
874 874
                         $xml = new FluidXml();
875 875
                         $xml->appendChild(['child1' => 'value1', 'child2' => 'value2'])
876
-                             ->appendChild('parent', true)
877
-                             ->appendChild(['child3' => 'value3', 'child4' => 'value4']);
876
+                                ->appendChild('parent', true)
877
+                                ->appendChild(['child3' => 'value3', 'child4' => 'value4']);
878 878
 
879 879
                         $expected = "<doc>\n"
880
-                                  . "  <child1>value1</child1>\n"
881
-                                  . "  <child2>value2</child2>\n"
882
-                                  . "  <parent>\n"
883
-                                  . "    <child3>value3</child3>\n"
884
-                                  . "    <child4>value4</child4>\n"
885
-                                  . "  </parent>\n"
886
-                                  . "</doc>";
880
+                                        . "  <child1>value1</child1>\n"
881
+                                        . "  <child2>value2</child2>\n"
882
+                                        . "  <parent>\n"
883
+                                        . "    <child3>value3</child3>\n"
884
+                                        . "    <child4>value4</child4>\n"
885
+                                        . "  </parent>\n"
886
+                                        . "</doc>";
887 887
                         assert_equal_xml($xml, $expected);
888 888
 
889 889
                         $xml = new FluidXml();
890 890
                         $xml->appendChild([ 'child', ['child'], ['child' => 'value1'], ['child' => 'value2'] ])
891
-                             ->appendChild('parent', true)
892
-                             ->appendChild([ 'child', ['child'], ['child' => 'value3'], ['child' => 'value4'] ]);
891
+                                ->appendChild('parent', true)
892
+                                ->appendChild([ 'child', ['child'], ['child' => 'value3'], ['child' => 'value4'] ]);
893 893
 
894 894
                         $expected = "<doc>\n"
895
-                                  . "  <child/>\n"
896
-                                  . "  <child/>\n"
897
-                                  . "  <child>value1</child>\n"
898
-                                  . "  <child>value2</child>\n"
899
-                                  . "  <parent>\n"
900
-                                  . "    <child/>\n"
901
-                                  . "    <child/>\n"
902
-                                  . "    <child>value3</child>\n"
903
-                                  . "    <child>value4</child>\n"
904
-                                  . "  </parent>\n"
905
-                                  . "</doc>";
895
+                                        . "  <child/>\n"
896
+                                        . "  <child/>\n"
897
+                                        . "  <child>value1</child>\n"
898
+                                        . "  <child>value2</child>\n"
899
+                                        . "  <parent>\n"
900
+                                        . "    <child/>\n"
901
+                                        . "    <child/>\n"
902
+                                        . "    <child>value3</child>\n"
903
+                                        . "    <child>value4</child>\n"
904
+                                        . "  </parent>\n"
905
+                                        . "</doc>";
906 906
                         assert_equal_xml($xml, $expected);
907 907
                 });
908 908
 
909 909
                 it('should add a child with some attributes', function() {
910 910
                         $xml = new FluidXml();
911 911
                         $xml->appendChild('child1', ['class' => 'Class attr', 'id' => 'Id attr1'])
912
-                            ->appendChild('parent', true)
913
-                            ->appendChild('child2', ['class' => 'Class attr', 'id' => 'Id attr2']);
912
+                                ->appendChild('parent', true)
913
+                                ->appendChild('child2', ['class' => 'Class attr', 'id' => 'Id attr2']);
914 914
 
915 915
                         $expected = "<doc>\n"
916
-                                  . "  <child1 class=\"Class attr\" id=\"Id attr1\"/>\n"
917
-                                  . "  <parent>\n"
918
-                                  . "    <child2 class=\"Class attr\" id=\"Id attr2\"/>\n"
919
-                                  . "  </parent>\n"
920
-                                  . "</doc>";
916
+                                        . "  <child1 class=\"Class attr\" id=\"Id attr1\"/>\n"
917
+                                        . "  <parent>\n"
918
+                                        . "    <child2 class=\"Class attr\" id=\"Id attr2\"/>\n"
919
+                                        . "  </parent>\n"
920
+                                        . "</doc>";
921 921
                         assert_equal_xml($xml, $expected);
922 922
                 });
923 923
 
924 924
                 it('should add many children with some attributes', function() {
925 925
                         $xml = new FluidXml();
926 926
                         $xml->appendChild(['child1', 'child2'], ['class' => 'Class attr', 'id' => 'Id attr1'])
927
-                            ->appendChild('parent', true)
928
-                            ->appendChild(['child3', 'child4'], ['class' => 'Class attr', 'id' => 'Id attr2']);
927
+                                ->appendChild('parent', true)
928
+                                ->appendChild(['child3', 'child4'], ['class' => 'Class attr', 'id' => 'Id attr2']);
929 929
 
930 930
                         $expected = "<doc>\n"
931
-                                  . "  <child1 class=\"Class attr\" id=\"Id attr1\"/>\n"
932
-                                  . "  <child2 class=\"Class attr\" id=\"Id attr1\"/>\n"
933
-                                  . "  <parent>\n"
934
-                                  . "    <child3 class=\"Class attr\" id=\"Id attr2\"/>\n"
935
-                                  . "    <child4 class=\"Class attr\" id=\"Id attr2\"/>\n"
936
-                                  . "  </parent>\n"
937
-                                  . "</doc>";
931
+                                        . "  <child1 class=\"Class attr\" id=\"Id attr1\"/>\n"
932
+                                        . "  <child2 class=\"Class attr\" id=\"Id attr1\"/>\n"
933
+                                        . "  <parent>\n"
934
+                                        . "    <child3 class=\"Class attr\" id=\"Id attr2\"/>\n"
935
+                                        . "    <child4 class=\"Class attr\" id=\"Id attr2\"/>\n"
936
+                                        . "  </parent>\n"
937
+                                        . "</doc>";
938 938
                         assert_equal_xml($xml, $expected);
939 939
                 });
940 940
 
941 941
                 it('should add children with some attributes and text using the @ syntax', function() {
942 942
                         $xml = new FluidXml();
943 943
                         $attrs = [ '@class' => 'Class attr',
944
-                                   '@'      => 'Text content',
945
-                                   '@id'    => 'Id attr' ];
944
+                                        '@'      => 'Text content',
945
+                                        '@id'    => 'Id attr' ];
946 946
                         $xml->appendChild(['child1' => $attrs ])
947
-                            ->appendChild(['child2' => $attrs ], true)
947
+                                ->appendChild(['child2' => $attrs ], true)
948 948
                                 ->appendChild(['child3' => $attrs ]);
949 949
 
950 950
                         $expected = "<doc>\n"
951
-                                  . "  <child1 class=\"Class attr\" id=\"Id attr\">Text content</child1>\n"
952
-                                  . "  <child2 class=\"Class attr\" id=\"Id attr\">"
953
-                                  .      "Text content"
954
-                                  .      "<child3 class=\"Class attr\" id=\"Id attr\">Text content</child3>"
955
-                                  .    "</child2>\n"
956
-                                  . "</doc>";
951
+                                        . "  <child1 class=\"Class attr\" id=\"Id attr\">Text content</child1>\n"
952
+                                        . "  <child2 class=\"Class attr\" id=\"Id attr\">"
953
+                                        .      "Text content"
954
+                                        .      "<child3 class=\"Class attr\" id=\"Id attr\">Text content</child3>"
955
+                                        .    "</child2>\n"
956
+                                        . "</doc>";
957 957
                         assert_equal_xml($xml, $expected);
958 958
                 });
959 959
 
@@ -984,26 +984,26 @@  discard block
 block discarded – undo
984 984
                         $xml->namespace(new FluidNamespace('x', 'x.com'));
985 985
                         $xml->namespace(fluidns('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT));
986 986
                         $xml->appendChild('x:xTag1', true)
987
-                            ->appendChild('x:xTag2');
987
+                                ->appendChild('x:xTag2');
988 988
                         $xml->appendChild('xx:xxTag1', true)
989
-                            ->appendChild('xx:xxTag2')
990
-                            ->appendChild('tag3');
989
+                                ->appendChild('xx:xxTag2')
990
+                                ->appendChild('tag3');
991 991
 
992 992
                         $expected = "<doc>\n"
993
-                                  . "  <x:xTag1 xmlns:x=\"x.com\">\n"
994
-                                  . "    <x:xTag2/>\n"
995
-                                  . "  </x:xTag1>\n"
996
-                                  . "  <xxTag1 xmlns=\"xx.com\">\n"
997
-                                  . "    <xxTag2/>\n"
998
-                                  . "    <tag3/>\n"
999
-                                  . "  </xxTag1>\n"
1000
-                                  . "</doc>";
993
+                                        . "  <x:xTag1 xmlns:x=\"x.com\">\n"
994
+                                        . "    <x:xTag2/>\n"
995
+                                        . "  </x:xTag1>\n"
996
+                                        . "  <xxTag1 xmlns=\"xx.com\">\n"
997
+                                        . "    <xxTag2/>\n"
998
+                                        . "    <tag3/>\n"
999
+                                        . "  </xxTag1>\n"
1000
+                                        . "</doc>";
1001 1001
                         assert_equal_xml($xml, $expected);
1002 1002
                 });
1003 1003
 
1004 1004
                 $doc = "<doc>\n"
1005
-                     . "  <parent>content</parent>\n"
1006
-                     . "</doc>";
1005
+                        . "  <parent>content</parent>\n"
1006
+                        . "</doc>";
1007 1007
                 $dom = new \DOMDocument();
1008 1008
                 $dom->loadXML($doc);
1009 1009
 
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
                         $xml->appendChild('<root1/><root2/>');
1021 1021
 
1022 1022
                         $expected = "<root1/>\n"
1023
-                                  . "<root2/>";
1023
+                                        . "<root2/>";
1024 1024
                         assert_equal_xml($xml, $expected);
1025 1025
                 });
1026 1026
 
@@ -1029,21 +1029,21 @@  discard block
 block discarded – undo
1029 1029
                         $xml->appendChild('<child1/><child2/>');
1030 1030
 
1031 1031
                         $expected = "<doc>\n"
1032
-                                  . "  <child1/>\n"
1033
-                                  . "  <child2/>\n"
1034
-                                  . "</doc>";
1032
+                                        . "  <child1/>\n"
1033
+                                        . "  <child2/>\n"
1034
+                                        . "</doc>";
1035 1035
                         assert_equal_xml($xml, $expected);
1036 1036
 
1037 1037
                         $xml = new FluidXml();
1038 1038
                         $xml->appendChild('parent', true)
1039
-                            ->appendChild('<child1/><child2/>');
1039
+                                ->appendChild('<child1/><child2/>');
1040 1040
 
1041 1041
                         $expected = "<doc>\n"
1042
-                                  . "  <parent>\n"
1043
-                                  . "    <child1/>\n"
1044
-                                  . "    <child2/>\n"
1045
-                                  . "  </parent>\n"
1046
-                                  . "</doc>";
1042
+                                        . "  <parent>\n"
1043
+                                        . "    <child1/>\n"
1044
+                                        . "    <child2/>\n"
1045
+                                        . "  </parent>\n"
1046
+                                        . "</doc>";
1047 1047
                         assert_equal_xml($xml, $expected);
1048 1048
                 });
1049 1049
 
@@ -1110,14 +1110,14 @@  discard block
 block discarded – undo
1110 1110
                         $fxml = FluidXml::load($dom)->query('/doc/parent');
1111 1111
                         $xml  = new FluidXml();
1112 1112
                         $xml->appendChild([ $fxml,
1113
-                                            'imported' => $fxml ]);
1113
+                                                'imported' => $fxml ]);
1114 1114
 
1115 1115
                         $expected = "<doc>\n"
1116
-                                  . "  <parent>content</parent>\n"
1117
-                                  . "  <imported>\n"
1118
-                                  . "    <parent>content</parent>\n"
1119
-                                  . "  </imported>\n"
1120
-                                  . "</doc>";
1116
+                                        . "  <parent>content</parent>\n"
1117
+                                        . "  <imported>\n"
1118
+                                        . "    <parent>content</parent>\n"
1119
+                                        . "  </imported>\n"
1120
+                                        . "</doc>";
1121 1121
                         assert_equal_xml($xml, $expected);
1122 1122
                 });
1123 1123
 
@@ -1175,14 +1175,14 @@  discard block
 block discarded – undo
1175 1175
                 it('should add a sibling node before a node', function() {
1176 1176
                         $xml = new FluidXml();
1177 1177
                         $xml->appendChild('parent', true)
1178
-                            ->prependSibling('sibling1')
1179
-                            ->prependSibling('sibling2');
1178
+                                ->prependSibling('sibling1')
1179
+                                ->prependSibling('sibling2');
1180 1180
 
1181 1181
                         $expected = "<doc>\n"
1182
-                                  . "  <sibling1/>\n"
1183
-                                  . "  <sibling2/>\n"
1184
-                                  . "  <parent/>\n"
1185
-                                  . "</doc>";
1182
+                                        . "  <sibling1/>\n"
1183
+                                        . "  <sibling2/>\n"
1184
+                                        . "  <parent/>\n"
1185
+                                        . "</doc>";
1186 1186
                         assert_equal_xml($xml, $expected);
1187 1187
                 });
1188 1188
 
@@ -1194,17 +1194,17 @@  discard block
 block discarded – undo
1194 1194
                         $xml->prependSibling($dom);
1195 1195
 
1196 1196
                         $expected = "<parent>content</parent>\n"
1197
-                                  . "<doc/>";
1197
+                                        . "<doc/>";
1198 1198
                         assert_equal_xml($xml, $expected);
1199 1199
 
1200 1200
                         $xml = new FluidXml();
1201 1201
                         $xml->appendChild('sibling', true)
1202
-                            ->prependSibling($dom);
1202
+                                ->prependSibling($dom);
1203 1203
 
1204 1204
                         $expected = "<doc>\n"
1205
-                                  . "  <parent>content</parent>\n"
1206
-                                  . "  <sibling/>\n"
1207
-                                  . "</doc>";
1205
+                                        . "  <parent>content</parent>\n"
1206
+                                        . "  <sibling/>\n"
1207
+                                        . "</doc>";
1208 1208
                         assert_equal_xml($xml, $expected);
1209 1209
                 });
1210 1210
         });
@@ -1251,14 +1251,14 @@  discard block
 block discarded – undo
1251 1251
                 it('should add a sibling node after a node', function() {
1252 1252
                         $xml = new FluidXml();
1253 1253
                         $xml->appendChild('parent', true)
1254
-                            ->appendSibling('sibling1')
1255
-                            ->appendSibling('sibling2');
1254
+                                ->appendSibling('sibling1')
1255
+                                ->appendSibling('sibling2');
1256 1256
 
1257 1257
                         $expected = "<doc>\n"
1258
-                                  . "  <parent/>\n"
1259
-                                  . "  <sibling2/>\n"
1260
-                                  . "  <sibling1/>\n"
1261
-                                  . "</doc>";
1258
+                                        . "  <parent/>\n"
1259
+                                        . "  <sibling2/>\n"
1260
+                                        . "  <sibling1/>\n"
1261
+                                        . "</doc>";
1262 1262
                         assert_equal_xml($xml, $expected);
1263 1263
                 });
1264 1264
 
@@ -1270,17 +1270,17 @@  discard block
 block discarded – undo
1270 1270
                         $xml->appendSibling($dom);
1271 1271
 
1272 1272
                         $expected = "<doc/>\n"
1273
-                                  . "<parent>content</parent>";
1273
+                                        . "<parent>content</parent>";
1274 1274
                         assert_equal_xml($xml, $expected);
1275 1275
 
1276 1276
                         $xml = new FluidXml();
1277 1277
                         $xml->appendChild('sibling', true)
1278
-                            ->appendSibling($dom);
1278
+                                ->appendSibling($dom);
1279 1279
 
1280 1280
                         $expected = "<doc>\n"
1281
-                                  . "  <sibling/>\n"
1282
-                                  . "  <parent>content</parent>\n"
1283
-                                  . "</doc>";
1281
+                                        . "  <sibling/>\n"
1282
+                                        . "  <parent>content</parent>\n"
1283
+                                        . "</doc>";
1284 1284
                         assert_equal_xml($xml, $expected);
1285 1285
                 });
1286 1286
         });
@@ -1293,14 +1293,14 @@  discard block
 block discarded – undo
1293 1293
                 it('should set the attributes of the root node', function() {
1294 1294
                         $xml = new FluidXml();
1295 1295
                         $xml->setAttribute('attr1', 'Attr1 Value')
1296
-                            ->setAttribute('attr2', 'Attr2 Value');
1296
+                                ->setAttribute('attr2', 'Attr2 Value');
1297 1297
 
1298 1298
                         $expected = "<doc attr1=\"Attr1 Value\" attr2=\"Attr2 Value\"/>";
1299 1299
                         assert_equal_xml($xml, $expected);
1300 1300
 
1301 1301
                         $xml = new FluidXml();
1302 1302
                         $xml->setAttribute(['attr1' => 'Attr1 Value',
1303
-                                            'attr2' => 'Attr2 Value']);
1303
+                                                'attr2' => 'Attr2 Value']);
1304 1304
 
1305 1305
                         $expected = "<doc attr1=\"Attr1 Value\" attr2=\"Attr2 Value\"/>";
1306 1306
                         assert_equal_xml($xml, $expected);
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
                 it('should change the attributes of the root node', function() {
1310 1310
                         $xml = new FluidXml();
1311 1311
                         $xml->setAttribute('attr1', 'Attr1 Value')
1312
-                            ->setAttribute('attr2', 'Attr2 Value');
1312
+                                ->setAttribute('attr2', 'Attr2 Value');
1313 1313
 
1314 1314
                         $xml->setAttribute('attr2', 'Attr2 New Value');
1315 1315
 
@@ -1325,46 +1325,46 @@  discard block
 block discarded – undo
1325 1325
                 it('should set the attributes of a node', function() {
1326 1326
                         $xml = new FluidXml();
1327 1327
                         $xml->appendChild('child', true)
1328
-                            ->setAttribute('attr1', 'Attr1 Value')
1329
-                            ->setAttribute('attr2', 'Attr2 Value');
1328
+                                ->setAttribute('attr1', 'Attr1 Value')
1329
+                                ->setAttribute('attr2', 'Attr2 Value');
1330 1330
 
1331 1331
                         $expected = "<doc>\n"
1332
-                                  . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 Value\"/>\n"
1333
-                                  . "</doc>";
1332
+                                        . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 Value\"/>\n"
1333
+                                        . "</doc>";
1334 1334
                         assert_equal_xml($xml, $expected);
1335 1335
 
1336 1336
                         $xml = new FluidXml();
1337 1337
                         $xml->appendChild('child', true)
1338
-                            ->setAttribute(['attr1' => 'Attr1 Value',
1339
-                                            'attr2' => 'Attr2 Value']);
1338
+                                ->setAttribute(['attr1' => 'Attr1 Value',
1339
+                                                'attr2' => 'Attr2 Value']);
1340 1340
 
1341 1341
                         $expected = "<doc>\n"
1342
-                                  . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 Value\"/>\n"
1343
-                                  . "</doc>";
1342
+                                        . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 Value\"/>\n"
1343
+                                        . "</doc>";
1344 1344
                         assert_equal_xml($xml, $expected);
1345 1345
                 });
1346 1346
 
1347 1347
                 it('should change the attributes of a node', function() {
1348 1348
                         $xml = new FluidXml();
1349 1349
                         $xml->appendChild('child', true)
1350
-                            ->setAttribute('attr1', 'Attr1 Value')
1351
-                            ->setAttribute('attr2', 'Attr2 Value')
1352
-                            ->setAttribute('attr2', 'Attr2 New Value');
1350
+                                ->setAttribute('attr1', 'Attr1 Value')
1351
+                                ->setAttribute('attr2', 'Attr2 Value')
1352
+                                ->setAttribute('attr2', 'Attr2 New Value');
1353 1353
 
1354 1354
                         $expected = "<doc>\n"
1355
-                                  . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 New Value\"/>\n"
1356
-                                  . "</doc>";
1355
+                                        . "  <child attr1=\"Attr1 Value\" attr2=\"Attr2 New Value\"/>\n"
1356
+                                        . "</doc>";
1357 1357
                         assert_equal_xml($xml, $expected);
1358 1358
 
1359 1359
                         $xml = new FluidXml();
1360 1360
                         $xml->appendChild('child', true)
1361
-                            ->setAttribute(['attr1' => 'Attr1 Value',
1362
-                                            'attr2' => 'Attr2 Value'])
1363
-                            ->setAttribute('attr1', 'Attr1 New Value');
1361
+                                ->setAttribute(['attr1' => 'Attr1 Value',
1362
+                                                'attr2' => 'Attr2 Value'])
1363
+                                ->setAttribute('attr1', 'Attr1 New Value');
1364 1364
 
1365 1365
                         $expected = "<doc>\n"
1366
-                                  . "  <child attr1=\"Attr1 New Value\" attr2=\"Attr2 Value\"/>\n"
1367
-                                  . "</doc>";
1366
+                                        . "  <child attr1=\"Attr1 New Value\" attr2=\"Attr2 Value\"/>\n"
1367
+                                        . "</doc>";
1368 1368
                         assert_equal_xml($xml, $expected);
1369 1369
                 });
1370 1370
         });
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
                 it('should add text to the root node', function() {
1378 1378
                         $xml = new FluidXml();
1379 1379
                         $xml->appendText('First Line')
1380
-                            ->appendText('Second Line');
1380
+                                ->appendText('Second Line');
1381 1381
 
1382 1382
                         $expected = "<doc>First LineSecond Line</doc>";
1383 1383
                         assert_equal_xml($xml, $expected);
@@ -1387,11 +1387,11 @@  discard block
 block discarded – undo
1387 1387
                         $xml = new FluidXml();
1388 1388
                         $cx = $xml->appendChild('p', true);
1389 1389
                         $cx->appendText('First Line')
1390
-                           ->appendText('Second Line');
1390
+                                ->appendText('Second Line');
1391 1391
 
1392 1392
                         $expected = "<doc>\n"
1393
-                                  . "  <p>First LineSecond Line</p>\n"
1394
-                                  . "</doc>";
1393
+                                        . "  <p>First LineSecond Line</p>\n"
1394
+                                        . "</doc>";
1395 1395
                         assert_equal_xml($xml, $expected);
1396 1396
                 });
1397 1397
         });
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
                 it('should set/change the text of the root node', function() {
1405 1405
                         $xml = new FluidXml();
1406 1406
                         $xml->setText('First Text')
1407
-                            ->setText('Second Text');
1407
+                                ->setText('Second Text');
1408 1408
 
1409 1409
                         $expected = "<doc>Second Text</doc>";
1410 1410
                         assert_equal_xml($xml, $expected);
@@ -1414,11 +1414,11 @@  discard block
 block discarded – undo
1414 1414
                         $xml = new FluidXml();
1415 1415
                         $cx = $xml->appendChild('p', true);
1416 1416
                         $cx->setText('First Text')
1417
-                           ->setText('Second Text');
1417
+                                ->setText('Second Text');
1418 1418
 
1419 1419
                         $expected = "<doc>\n"
1420
-                                  . "  <p>Second Text</p>\n"
1421
-                                  . "</doc>";
1420
+                                        . "  <p>Second Text</p>\n"
1421
+                                        . "</doc>";
1422 1422
                         assert_equal_xml($xml, $expected);
1423 1423
                 });
1424 1424
         });
@@ -1431,12 +1431,12 @@  discard block
 block discarded – undo
1431 1431
                 it('should add CDATA to the root node', function() {
1432 1432
                         $xml = new FluidXml();
1433 1433
                         $xml->appendCdata('// <, > are characters that should be escaped in a XML context.')
1434
-                            ->appendCdata('// Even & is a characters that should be escaped in a XML context.');
1434
+                                ->appendCdata('// Even & is a characters that should be escaped in a XML context.');
1435 1435
 
1436 1436
                         $expected = "<doc>"
1437
-                                  . "<![CDATA[// <, > are characters that should be escaped in a XML context.]]>"
1438
-                                  . "<![CDATA[// Even & is a characters that should be escaped in a XML context.]]>"
1439
-                                  . "</doc>";
1437
+                                        . "<![CDATA[// <, > are characters that should be escaped in a XML context.]]>"
1438
+                                        . "<![CDATA[// Even & is a characters that should be escaped in a XML context.]]>"
1439
+                                        . "</doc>";
1440 1440
                         assert_equal_xml($xml, $expected);
1441 1441
                 });
1442 1442
 
@@ -1444,14 +1444,14 @@  discard block
 block discarded – undo
1444 1444
                         $xml = new FluidXml();
1445 1445
                         $cx = $xml->appendChild('pre', true);
1446 1446
                         $cx->appendCdata('// <, > are characters that should be escaped in a XML context.')
1447
-                           ->appendCdata('// Even & is a characters that should be escaped in a XML context.');
1447
+                                ->appendCdata('// Even & is a characters that should be escaped in a XML context.');
1448 1448
 
1449 1449
                         $expected = "<doc>\n"
1450
-                                  . "  <pre>"
1451
-                                  . "<![CDATA[// <, > are characters that should be escaped in a XML context.]]>"
1452
-                                  . "<![CDATA[// Even & is a characters that should be escaped in a XML context.]]>"
1453
-                                  .    "</pre>\n"
1454
-                                  . "</doc>";
1450
+                                        . "  <pre>"
1451
+                                        . "<![CDATA[// <, > are characters that should be escaped in a XML context.]]>"
1452
+                                        . "<![CDATA[// Even & is a characters that should be escaped in a XML context.]]>"
1453
+                                        .    "</pre>\n"
1454
+                                        . "</doc>";
1455 1455
                         assert_equal_xml($xml, $expected);
1456 1456
                 });
1457 1457
         });
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
                 it('should set/change the CDATA of the root node', function() {
1465 1465
                         $xml = new FluidXml();
1466 1466
                         $xml->setCdata('First Data')
1467
-                            ->setCdata('Second Data');
1467
+                                ->setCdata('Second Data');
1468 1468
 
1469 1469
                         $expected = "<doc><![CDATA[Second Data]]></doc>";
1470 1470
                         assert_equal_xml($xml, $expected);
@@ -1474,24 +1474,24 @@  discard block
 block discarded – undo
1474 1474
                         $xml = new FluidXml();
1475 1475
                         $cx = $xml->appendChild('p', true);
1476 1476
                         $cx->setCdata('First Data')
1477
-                           ->setCdata('Second Data');
1477
+                                ->setCdata('Second Data');
1478 1478
 
1479 1479
                         $expected = "<doc>\n"
1480
-                                  . "  <p><![CDATA[Second Data]]></p>\n"
1481
-                                  . "</doc>";
1480
+                                        . "  <p><![CDATA[Second Data]]></p>\n"
1481
+                                        . "</doc>";
1482 1482
                         assert_equal_xml($xml, $expected);
1483 1483
                 });
1484 1484
         });
1485 1485
 
1486 1486
         describe('.remove', function() {
1487 1487
                 $expected = "<doc>\n"
1488
-                          . "  <parent/>\n"
1489
-                          . "</doc>";
1488
+                                . "  <parent/>\n"
1489
+                                . "</doc>";
1490 1490
 
1491 1491
                 $new_doc = function() {
1492 1492
                         $xml = new FluidXml();
1493 1493
                         $xml->appendChild('parent', true)
1494
-                            ->appendChild(['child1', 'child2'], ['class'=>'removable']);
1494
+                                ->appendChild(['child1', 'child2'], ['class'=>'removable']);
1495 1495
 
1496 1496
                         return $xml;
1497 1497
                 };
@@ -1573,10 +1573,10 @@  discard block
 block discarded – undo
1573 1573
                                 ->appendChild('child', 'content');
1574 1574
 
1575 1575
                         $expected = "<doc>\n"
1576
-                                  . "  <parent>\n"
1577
-                                  . "    <child>content</child>\n"
1578
-                                  . "  </parent>\n"
1579
-                                  . "</doc>";
1576
+                                        . "  <parent>\n"
1577
+                                        . "    <child>content</child>\n"
1578
+                                        . "  </parent>\n"
1579
+                                        . "</doc>";
1580 1580
 
1581 1581
                         assert_equal_xml($xml, $expected);
1582 1582
                 });
@@ -1588,10 +1588,10 @@  discard block
 block discarded – undo
1588 1588
 
1589 1589
                         $actual   = $xml->xml(true);
1590 1590
                         $expected = "<doc>\n"
1591
-                                  . "  <parent>\n"
1592
-                                  . "    <child>content</child>\n"
1593
-                                  . "  </parent>\n"
1594
-                                  . "</doc>";
1591
+                                        . "  <parent>\n"
1592
+                                        . "    <child>content</child>\n"
1593
+                                        . "  </parent>\n"
1594
+                                        . "</doc>";
1595 1595
                         \assert($actual === $expected, __($actual, $expected));
1596 1596
                 });
1597 1597
 
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 
1613 1613
                         $actual   = $xml->query('//child')->xml();
1614 1614
                         $expected = "<child>content1</child>\n"
1615
-                                  . "<child>content2</child>";
1615
+                                        . "<child>content2</child>";
1616 1616
                         \assert($actual === $expected, __($actual, $expected));
1617 1617
                 });
1618 1618
         });
@@ -1625,11 +1625,11 @@  discard block
 block discarded – undo
1625 1625
                 it('should behave like .appendChild', function() {
1626 1626
                         $xml = new FluidXml();
1627 1627
                         $xml->appendChild('parent', true)
1628
-                            ->appendChild(['child1', 'child2'], ['class'=>'child']);
1628
+                                ->appendChild(['child1', 'child2'], ['class'=>'child']);
1629 1629
 
1630 1630
                         $alias = new FluidXml();
1631 1631
                         $alias->add('parent', true)
1632
-                              ->add(['child1', 'child2'], ['class'=>'child']);
1632
+                                ->add(['child1', 'child2'], ['class'=>'child']);
1633 1633
 
1634 1634
                         $actual   = $xml->xml();
1635 1635
                         $expected = $alias->xml();
@@ -1645,11 +1645,11 @@  discard block
 block discarded – undo
1645 1645
                 it('should behave like .prependSibling', function() {
1646 1646
                         $xml = new FluidXml();
1647 1647
                         $xml->prependSibling('sibling1', true)
1648
-                            ->prependSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1648
+                                ->prependSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1649 1649
 
1650 1650
                         $alias = new FluidXml();
1651 1651
                         $alias->prepend('sibling1', true)
1652
-                              ->prepend(['sibling2', 'sibling3'], ['class'=>'sibling']);
1652
+                                ->prepend(['sibling2', 'sibling3'], ['class'=>'sibling']);
1653 1653
 
1654 1654
                         $actual   = $xml->xml();
1655 1655
                         $expected = $alias->xml();
@@ -1665,11 +1665,11 @@  discard block
 block discarded – undo
1665 1665
                 it('should behave like .prependSibling', function() {
1666 1666
                         $xml = new FluidXml();
1667 1667
                         $xml->prependSibling('sibling1', true)
1668
-                            ->prependSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1668
+                                ->prependSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1669 1669
 
1670 1670
                         $alias = new FluidXml();
1671 1671
                         $alias->insertSiblingBefore('sibling1', true)
1672
-                              ->insertSiblingBefore(['sibling2', 'sibling3'], ['class'=>'sibling']);
1672
+                                ->insertSiblingBefore(['sibling2', 'sibling3'], ['class'=>'sibling']);
1673 1673
 
1674 1674
                         $actual   = $xml->xml();
1675 1675
                         $expected = $alias->xml();
@@ -1685,11 +1685,11 @@  discard block
 block discarded – undo
1685 1685
                 it('should behave like .appendSibling', function() {
1686 1686
                         $xml = new FluidXml();
1687 1687
                         $xml->appendSibling('sibling1', true)
1688
-                            ->appendSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1688
+                                ->appendSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1689 1689
 
1690 1690
                         $alias = new FluidXml();
1691 1691
                         $alias->append('sibling1', true)
1692
-                              ->append(['sibling2', 'sibling3'], ['class'=>'sibling']);
1692
+                                ->append(['sibling2', 'sibling3'], ['class'=>'sibling']);
1693 1693
 
1694 1694
                         $actual   = $xml->xml();
1695 1695
                         $expected = $alias->xml();
@@ -1705,11 +1705,11 @@  discard block
 block discarded – undo
1705 1705
                 it('should behave like .appendSibling', function() {
1706 1706
                         $xml = new FluidXml();
1707 1707
                         $xml->appendSibling('sibling1', true)
1708
-                            ->appendSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1708
+                                ->appendSibling(['sibling2', 'sibling3'], ['class'=>'sibling']);
1709 1709
 
1710 1710
                         $alias = new FluidXml();
1711 1711
                         $alias->insertSiblingAfter('sibling1', true)
1712
-                              ->insertSiblingAfter(['sibling2', 'sibling3'], ['class'=>'sibling']);
1712
+                                ->insertSiblingAfter(['sibling2', 'sibling3'], ['class'=>'sibling']);
1713 1713
 
1714 1714
                         $actual   = $xml->xml();
1715 1715
                         $expected = $alias->xml();
@@ -1725,17 +1725,17 @@  discard block
 block discarded – undo
1725 1725
                 it('should behave like .setAttribute', function() {
1726 1726
                         $xml = new FluidXml();
1727 1727
                         $xml->setAttribute('attr1', 'Attr1 Value')
1728
-                            ->setAttribute(['attr2' => 'Attr2 Value', 'attr3' => 'Attr3 Value'])
1729
-                            ->appendChild('child', true)
1730
-                            ->setAttribute('attr4', 'Attr4 Value')
1731
-                            ->setAttribute(['attr5' => 'Attr5 Value', 'attr6' => 'Attr6 Value']);
1728
+                                ->setAttribute(['attr2' => 'Attr2 Value', 'attr3' => 'Attr3 Value'])
1729
+                                ->appendChild('child', true)
1730
+                                ->setAttribute('attr4', 'Attr4 Value')
1731
+                                ->setAttribute(['attr5' => 'Attr5 Value', 'attr6' => 'Attr6 Value']);
1732 1732
 
1733 1733
                         $alias = new FluidXml();
1734 1734
                         $alias->attr('attr1', 'Attr1 Value')
1735
-                              ->attr(['attr2' => 'Attr2 Value', 'attr3' => 'Attr3 Value'])
1736
-                              ->appendChild('child', true)
1737
-                              ->attr('attr4', 'Attr4 Value')
1738
-                              ->attr(['attr5' => 'Attr5 Value', 'attr6' => 'Attr6 Value']);
1735
+                                ->attr(['attr2' => 'Attr2 Value', 'attr3' => 'Attr3 Value'])
1736
+                                ->appendChild('child', true)
1737
+                                ->attr('attr4', 'Attr4 Value')
1738
+                                ->attr(['attr5' => 'Attr5 Value', 'attr6' => 'Attr6 Value']);
1739 1739
 
1740 1740
                         $actual   = $xml->xml();
1741 1741
                         $expected = $alias->xml();
@@ -1751,13 +1751,13 @@  discard block
 block discarded – undo
1751 1751
                 it('should behave like .setText', function() {
1752 1752
                         $xml = new FluidXml();
1753 1753
                         $xml->setText('Text1')
1754
-                            ->appendChild('child', true)
1755
-                            ->setText('Text2');
1754
+                                ->appendChild('child', true)
1755
+                                ->setText('Text2');
1756 1756
 
1757 1757
                         $alias = new FluidXml();
1758 1758
                         $alias->text('Text1')
1759
-                              ->appendChild('child', true)
1760
-                              ->text('Text2');
1759
+                                ->appendChild('child', true)
1760
+                                ->text('Text2');
1761 1761
 
1762 1762
                         $actual   = $xml->xml();
1763 1763
                         $expected = $alias->xml();
@@ -1773,13 +1773,13 @@  discard block
 block discarded – undo
1773 1773
                 it('should behave like .setCdata', function() {
1774 1774
                         $xml = new FluidXml();
1775 1775
                         $xml->setCdata('Text1')
1776
-                            ->appendChild('child', true)
1777
-                            ->setCdata('Text2');
1776
+                                ->appendChild('child', true)
1777
+                                ->setCdata('Text2');
1778 1778
 
1779 1779
                         $alias = new FluidXml();
1780 1780
                         $alias->cdata('Text1')
1781
-                              ->appendChild('child', true)
1782
-                              ->cdata('Text2');
1781
+                                ->appendChild('child', true)
1782
+                                ->cdata('Text2');
1783 1783
 
1784 1784
                         $actual   = $xml->xml();
1785 1785
                         $expected = $alias->xml();
@@ -1929,25 +1929,25 @@  discard block
 block discarded – undo
1929 1929
                         \assert($actual === $expected, __($actual, $expected));
1930 1930
 
1931 1931
                         $expected = "<doc>\n"
1932
-                                  . "  <child1>\n"
1933
-                                  . "    <subchild1/>\n"
1934
-                                  . "    <subchild2/>\n"
1935
-                                  . "    <subchild3/>\n"
1936
-                                  . "    <subchild4/>\n"
1937
-                                  . "    <subchild5/>\n"
1938
-                                  . "    <subchild6/>\n"
1939
-                                  . "    <subchild7/>\n"
1940
-                                  . "  </child1>\n"
1941
-                                  . "  <child2>\n"
1942
-                                  . "    <subchild1/>\n"
1943
-                                  . "    <subchild2/>\n"
1944
-                                  . "    <subchild3/>\n"
1945
-                                  . "    <subchild4/>\n"
1946
-                                  . "    <subchild5/>\n"
1947
-                                  . "    <subchild6/>\n"
1948
-                                  . "    <subchild7/>\n"
1949
-                                  . "  </child2>\n"
1950
-                                  . "</doc>";
1932
+                                        . "  <child1>\n"
1933
+                                        . "    <subchild1/>\n"
1934
+                                        . "    <subchild2/>\n"
1935
+                                        . "    <subchild3/>\n"
1936
+                                        . "    <subchild4/>\n"
1937
+                                        . "    <subchild5/>\n"
1938
+                                        . "    <subchild6/>\n"
1939
+                                        . "    <subchild7/>\n"
1940
+                                        . "  </child1>\n"
1941
+                                        . "  <child2>\n"
1942
+                                        . "    <subchild1/>\n"
1943
+                                        . "    <subchild2/>\n"
1944
+                                        . "    <subchild3/>\n"
1945
+                                        . "    <subchild4/>\n"
1946
+                                        . "    <subchild5/>\n"
1947
+                                        . "    <subchild6/>\n"
1948
+                                        . "    <subchild7/>\n"
1949
+                                        . "  </child2>\n"
1950
+                                        . "</doc>";
1951 1951
                         assert_equal_xml($xml, $expected);
1952 1952
                 });
1953 1953
         });
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
                         $ns_uri  = 'x.com';
1987 1987
                         $ns_mode = FluidNamespace::MODE_EXPLICIT;
1988 1988
                         $args    = [ FluidNamespace::ID  => $ns_id,
1989
-                                     FluidNamespace::URI => $ns_uri ];
1989
+                                        FluidNamespace::URI => $ns_uri ];
1990 1990
                         $ns      = new FluidNamespace($args);
1991 1991
 
1992 1992
                         $actual   = $ns->id();
Please login to merge, or discard this patch.
source/FluidXml.php 1 patch
Indentation   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -136,7 +136,6 @@  discard block
 block discarded – undo
136 136
          *
137 137
          * ```php
138 138
          * $xml = fluidxml();
139
-
140 139
          * $xml->query("/doc/book[@id='123']");
141 140
          *
142 141
          * // Relative queries are valid.
@@ -156,7 +155,6 @@  discard block
 block discarded – undo
156 155
          *
157 156
          * ```php
158 157
          * $xml = fluidxml();
159
-
160 158
          * $xml->appendChild('title', 'The Theory Of Everything');
161 159
          * $xml->appendChild([ 'author' => 'S. Hawking' ]);
162 160
          *
@@ -234,8 +232,8 @@  discard block
 block discarded – undo
234 232
 class FluidXml implements FluidInterface
235 233
 {
236 234
         use FluidNamespaceTrait,
237
-            FluidXmlShadowTrait,        // For compatibility with PHP 5.6.
238
-            FluidContextShadowTrait;    // For compatibility with PHP 5.6.
235
+                FluidXmlShadowTrait,        // For compatibility with PHP 5.6.
236
+                FluidContextShadowTrait;    // For compatibility with PHP 5.6.
239 237
 
240 238
         const ROOT_NODE = 'doc';
241 239
 
@@ -266,9 +264,9 @@  discard block
 block discarded – undo
266 264
         public function __construct($root = null, $options = [])
267 265
         {
268 266
                 $defaults = [ 'root'       => self::ROOT_NODE,
269
-                              'version'    => '1.0',
270
-                              'encoding'   => 'UTF-8',
271
-                              'stylesheet' => null ];
267
+                                'version'    => '1.0',
268
+                                'encoding'   => 'UTF-8',
269
+                                'stylesheet' => null ];
272 270
 
273 271
                 if (\is_string($root)) {
274 272
                         // The root option can be specified as first argument
@@ -292,9 +290,9 @@  discard block
 block discarded – undo
292 290
 
293 291
                 if ($opts['stylesheet']) {
294 292
                         $attrs = "type=\"text/xsl\" "
295
-                               . "encoding=\"{$opts['encoding']}\" "
296
-                               . "indent=\"yes\" "
297
-                               . "href=\"{$opts['stylesheet']}\"";
293
+                                . "encoding=\"{$opts['encoding']}\" "
294
+                                . "indent=\"yes\" "
295
+                                . "href=\"{$opts['stylesheet']}\"";
298 296
                         $stylesheet = new \DOMProcessingInstruction('xml-stylesheet', $attrs);
299 297
 
300 298
                         $this->dom->insertBefore($stylesheet, $this->dom->documentElement);
@@ -493,7 +491,7 @@  discard block
 block discarded – undo
493 491
 class FluidContext implements FluidInterface, \ArrayAccess, \Iterator
494 492
 {
495 493
         use FluidNamespaceTrait,
496
-            FluidContextShadowTrait;    // For compatibility with PHP 5.6.
494
+                FluidContextShadowTrait;    // For compatibility with PHP 5.6.
497 495
 
498 496
         private $dom;
499 497
         private $nodes = [];
@@ -1142,8 +1140,8 @@  discard block
 block discarded – undo
1142 1140
         const MODE_EXPLICIT = 1;
1143 1141
 
1144 1142
         private $config = [ self::ID   => '',
1145
-                            self::URI  => '',
1146
-                            self::MODE => self::MODE_EXPLICIT ];
1143
+                                self::URI  => '',
1144
+                                self::MODE => self::MODE_EXPLICIT ];
1147 1145
 
1148 1146
         public function __construct($id, $uri, $mode = 1)
1149 1147
         {
Please login to merge, or discard this patch.
documents/Examples.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 // $booksheet = FluidXml::new('book', ['stylesheet' => 'http://domain.com/style.xsl']);
36 36
 
37 37
 $book->setAttribute('type', 'science')                  // It sets an attribute of the root node ('book').
38
-     ->appendChild([ 'title'  => 'The Theory Of Everything',
39
-                     'author' => 'S. Hawking' ]);       // It creates two nodes, each one with some text inside.
38
+        ->appendChild([ 'title'  => 'The Theory Of Everything',
39
+                        'author' => 'S. Hawking' ]);       // It creates two nodes, each one with some text inside.
40 40
 
41 41
 echo $book->xml();                                      // Exports the xml document as a string.
42 42
 echo "————————————————————————————————————————————————————————————————————————————————\n";
@@ -83,35 +83,35 @@  discard block
 block discarded – undo
83 83
 $food = fluidxml('food');
84 84
 
85 85
 $food->add('fruit')               // A 'fruit' node with an empty content.
86
-     ->add('fruit', 'orange');    // A 'fruit' node with 'orange' as content.
86
+        ->add('fruit', 'orange');    // A 'fruit' node with 'orange' as content.
87 87
 
88 88
 // A node can have even a bunch of attributes.
89 89
 $food->add('fruit', 'apple', [ 'price' => 'expensive',
90
-                               'color' => 'red' ]);
90
+                                'color' => 'red' ]);
91 91
 
92 92
 // Batch insertion of nodes.
93 93
 $food->add([ 'cake'  => 'Tiramisu',
94
-             'pizza' => 'Margherita' ]);
94
+                'pizza' => 'Margherita' ]);
95 95
 
96 96
 // PHP arrays can't contain identical keys.
97 97
 // But it's still possible to create, in a batch operation, nodes with the same tag.
98 98
 $food->add([ [ 'pasta' => 'Carbonara' ],
99
-             [ 'pasta' => 'Matriciana' ] ]);
99
+                [ 'pasta' => 'Matriciana' ] ]);
100 100
 
101 101
 // A bunch of egg's all with the same price.
102 102
 $food->add([ ['egg'], ['egg'], ['egg'] ], ['price' => '0.25']);
103 103
 
104 104
 // Complex array structures are supported too.
105 105
 $food->add([ 'menu' => [
106
-                 'pasta' => [
107
-                     'spaghetti' => [
108
-                         '@id'      => '123',
109
-                         '@country' => 'Italy',
110
-                         '@'        => 'Spaghetti are an Italian dish...',
106
+                        'pasta' => [
107
+                        'spaghetti' => [
108
+                                '@id'      => '123',
109
+                                '@country' => 'Italy',
110
+                                '@'        => 'Spaghetti are an Italian dish...',
111 111
 
112
-                         'variants' => [
113
-                             'tomato' => [ '@type' => 'vegan' ],
114
-                             'egg'    => [ '@type' => 'vegetarian' ] ]]]]]);
112
+                                'variants' => [
113
+                                'tomato' => [ '@type' => 'vegan' ],
114
+                                'egg'    => [ '@type' => 'vegetarian' ] ]]]]]);
115 115
 
116 116
 echo $food->xml();
117 117
 echo "————————————————————————————————————————————————————————————————————————————————\n";
@@ -188,10 +188,10 @@  discard block
 block discarded – undo
188 188
 $fluid = fluidxml();
189 189
 
190 190
 $fluid->add($other)                                     // Imports a FluidXml instance.
191
-      ->add([ 'query'     => $fluid->query('//meta'),   // Imports a FluidXml query.
192
-              'dom'       => $dom,                      // Imports a DOMDocument.
193
-              'domnodes'  => $dom->childNodes,          // Imports a DOMNodeList.
194
-              'simplexml' => $simplexml ]);             // Imports a SimpleXMLElement.
191
+        ->add([ 'query'     => $fluid->query('//meta'),   // Imports a FluidXml query.
192
+                'dom'       => $dom,                      // Imports a DOMDocument.
193
+                'domnodes'  => $dom->childNodes,          // Imports a DOMNodeList.
194
+                'simplexml' => $simplexml ]);             // Imports a SimpleXMLElement.
195 195
 
196 196
 
197 197
 
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 
212 212
 $book->query('//chapter')
213 213
         ->attr('lang', 'en')
214
-     ->query('..')
214
+        ->query('..')
215 215
         ->attr('lang', 'en')
216
-     ->query('../title')
216
+        ->query('../title')
217 217
         ->attr('lang', 'en');
218 218
 
219 219
 /*
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
 
296 296
 $xhtml = fluidns('xhtml', 'http://www.w3.org/1999/xhtml');
297 297
 $book->namespace($xhtml)
298
-     ->namespace('svg', 'http://www.w3.org/2000/svg')
299
-     ->namespace('xsl', 'http://www.w3.org/TR/xsl', FluidNamespace::MODE_IMPLICIT)
300
-     ->add('xhtml:h1')
301
-     ->add([ 'xsl:template'  => [ 'xsl:variable' ] ])
302
-     ->query('//xhtml:h1')
303
-     ->add('svg:shape');
298
+        ->namespace('svg', 'http://www.w3.org/2000/svg')
299
+        ->namespace('xsl', 'http://www.w3.org/TR/xsl', FluidNamespace::MODE_IMPLICIT)
300
+        ->add('xhtml:h1')
301
+        ->add([ 'xsl:template'  => [ 'xsl:variable' ] ])
302
+        ->query('//xhtml:h1')
303
+        ->add('svg:shape');
304 304
 
305 305
 echo $book->xml();
306 306
 echo "————————————————————————————————————————————————————————————————————————————————\n";
Please login to merge, or discard this patch.