Completed
Pull Request — master (#375)
by Michael
09:39 queued 04:34
created
www/src/AdminBundle/Tests/Service/TwineImport/FileExtractorTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     public function testExtract(): void
46 46
     {
47 47
         $tmpName = tempnam('/tmp', 'unittest');
48
-        $createdFilename = $tmpName.'.extracted';
48
+        $createdFilename = $tmpName . '.extracted';
49 49
         $content = <<< END
50 50
 nonsens
51 51
 lots of stuff
Please login to merge, or discard this patch.
www/src/AdminBundle/Service/TwineImport/FileExtractor.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@
 block discarded – undo
32 32
     public function extract(string $filename): string
33 33
     {
34 34
         if (!is_readable($filename)) {
35
-            throw new \InvalidArgumentException('Failed to read data from file ['.$filename.'].');
35
+            throw new \InvalidArgumentException('Failed to read data from file [' . $filename . '].');
36 36
         }
37
-        $extractedFilename = $filename.'.extracted';
37
+        $extractedFilename = $filename . '.extracted';
38 38
         $fileHandle = fopen($filename, 'r');
39 39
         $extractedFileHandle = fopen($extractedFilename, 'w');
40 40
         $writing = false;
Please login to merge, or discard this patch.
www/src/AdminBundle/Service/TwineImport/HitchParser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
         $contentArray = explode('-->', $content, 2);
68 68
 
69 69
         if (strlen($contentArray[0]) <= 0 || strlen($contentArray[1]) <= 0) {
70
-            throw new Exception("The Twine archive file contains a '".$name."' with the invalid element '[[".$contentArray[0]."-->".$contentArray[1]."]]'.");
70
+            throw new Exception("The Twine archive file contains a '" . $name . "' with the invalid element '[[" . $contentArray[0] . "-->" . $contentArray[1] . "]]'.");
71 71
         }
72 72
 
73 73
         $externalTextnode = $this->textnodeRepository->find($contentArray[1]);
74 74
 
75 75
         if (null === $externalTextnode) {
76
-            throw new Exception("There is a textnode which references the external Dembelo Textnode '".$contentArray[1]."', but a Dembelo Textnode with such an Id doesn't exist.");
76
+            throw new Exception("There is a textnode which references the external Dembelo Textnode '" . $contentArray[1] . "', but a Dembelo Textnode with such an Id doesn't exist.");
77 77
         }
78 78
 
79 79
         $hitch = array();
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
         $contentArray = explode("->", $content, 2);
96 96
 
97 97
         if (strlen($contentArray[0]) <= 0 || strlen($contentArray[1]) <= 0) {
98
-            throw new Exception("The Twine archive file contains a '".$name."' with the invalid element '[[".$contentArray[0]."->".$contentArray[1]."]]'.");
98
+            throw new Exception("The Twine archive file contains a '" . $name . "' with the invalid element '[[" . $contentArray[0] . "->" . $contentArray[1] . "]]'.");
99 99
         }
100 100
 
101 101
         if (array_key_exists($contentArray[1], $this->nodeNameMapping) !== true) {
102
-            throw new Exception("There is a textnode which references another textnode named '".$contentArray[1]."', but this textnode doesn't exist within the same story.");
102
+            throw new Exception("There is a textnode which references another textnode named '" . $contentArray[1] . "', but this textnode doesn't exist within the same story.");
103 103
         }
104 104
 
105 105
         $hitch = array();
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
         $contentArray = explode("<-", $content, 2);
122 122
 
123 123
         if (strlen($contentArray[0]) <= 0 || strlen($contentArray[1]) <= 0) {
124
-            throw new Exception("The Twine archive file contains a '".$name."' with the invalid element '[[".$contentArray[0]."<-".$contentArray[1]."]]'.");
124
+            throw new Exception("The Twine archive file contains a '" . $name . "' with the invalid element '[[" . $contentArray[0] . "<-" . $contentArray[1] . "]]'.");
125 125
         }
126 126
 
127 127
         if (array_key_exists($contentArray[0], $this->nodeNameMapping) !== true) {
128
-            throw new Exception("There is a textnode in the Twine archive file which references another textnode named '".$contentArray[0]."', but this textnode doesn't exist within the same story.");
128
+            throw new Exception("There is a textnode in the Twine archive file which references another textnode named '" . $contentArray[0] . "', but this textnode doesn't exist within the same story.");
129 129
         }
130 130
 
131 131
         $hitch = array();
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
     public function parseSimpleHitch(string $content, string $name): array
146 146
     {
147 147
         if (strlen($content) <= 0) {
148
-            throw new Exception("The Twine archive file contains a '".$name."' with the invalid element '[[".$content."]]'.");
148
+            throw new Exception("The Twine archive file contains a '" . $name . "' with the invalid element '[[" . $content . "]]'.");
149 149
         }
150 150
 
151 151
         if (array_key_exists($content, $this->nodeNameMapping) !== true) {
152
-            throw new Exception("There is a textnode in the Twine archive file which references another textnode named '".$content."', but this textnode doesn't exist within the same story.");
152
+            throw new Exception("There is a textnode in the Twine archive file which references another textnode named '" . $content . "', but this textnode doesn't exist within the same story.");
153 153
         }
154 154
 
155 155
         $hitch = array();
Please login to merge, or discard this patch.
www/src/AdminBundle/Service/TwineImport/FileCheck.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
         $peekData = fread($fileHandler, 1024);
41 41
 
42 42
         if ($peekData === false) {
43
-            throw new \Exception("Failed to read data from file '".$filename."'.");
43
+            throw new \Exception("Failed to read data from file '" . $filename . "'.");
44 44
         }
45 45
 
46 46
         $peekDataLength = strlen($peekData);
47 47
 
48 48
         if ($peekDataLength <= 0) {
49
-            throw new \Exception("File '".$filename."' seems to be empty.");
49
+            throw new \Exception("File '" . $filename . "' seems to be empty.");
50 50
         }
51 51
 
52 52
         for ($i = 0; $i < $peekDataLength; $i++) {
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
             }
60 60
 
61 61
             if ($peekDataLength - $i < $magicStringLength) {
62
-                throw new \Exception("File '".$filename."' isn't a Twine archive file.");
62
+                throw new \Exception("File '" . $filename . "' isn't a Twine archive file.");
63 63
             }
64 64
 
65 65
             if (substr($peekData, $i, $magicStringLength) !== self::OPENING_STRING) {
66
-                throw new \Exception("File '".$filename."' isn't a Twine archive file.");
66
+                throw new \Exception("File '" . $filename . "' isn't a Twine archive file.");
67 67
             }
68 68
 
69 69
             if (fseek($fileHandler, 0) !== 0) {
70
-                throw new \Exception("Couldn't reset reading position after the magic string in the Twine archive file '".$filename."' was checked.");
70
+                throw new \Exception("Couldn't reset reading position after the magic string in the Twine archive file '" . $filename . "' was checked.");
71 71
             }
72 72
 
73 73
             return true;
74 74
         }
75 75
 
76
-        throw new \Exception("File '".$filename."' doesn't seem to be a Twine archive file.");
76
+        throw new \Exception("File '" . $filename . "' doesn't seem to be a Twine archive file.");
77 77
     }
78 78
 }
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
www/src/AdminBundle/Tests/Model/ImportTwineTest.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
             ->willReturn('readable.extracted');
241 241
 
242 242
         self::$freadStack = [
243
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
244
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
243
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
244
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
245 245
             '<tw-passagedata pid="1" name="someNodeName" tags="Freigegeben ID:foobar" position="104,30">lorem impsum',
246 246
             'lorem impsum</tw-passagedata></tw-storydata>',
247 247
         ];
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
             ->willReturn('readable.extracted');
278 278
 
279 279
         self::$freadStack = [
280
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
281
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
280
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
281
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
282 282
             '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum',
283 283
             'lorem ipsum</tw-passagedata></tw-storydata>',
284 284
         ];
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
             ->willReturn('readable.extracted');
345 345
 
346 346
         self::$freadStack = [
347
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
348
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
347
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
348
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
349 349
             '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben" position="104,30">lorem ipsum',
350 350
             'lorem ipsum</tw-passagedata></tw-storydata>',
351 351
         ];
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
             ->willReturn('readable.extracted');
376 376
 
377 377
         self::$freadStack = [
378
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
379
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
378
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
379
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
380 380
             '<tw-passagedata pid="1" name="someNodeName1" tags="" position="104,30">lorem ipsum',
381 381
             'lorem ipsum</tw-passagedata></tw-storydata>',
382 382
         ];
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
             ->willReturn('readable.extracted');
407 407
 
408 408
         self::$freadStack = [
409
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
410
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
409
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
410
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
411 411
             '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum',
412 412
             'lorem ipsum</tw-passagedata></tw-storydata>',
413 413
         ];
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
             ->willReturn('readable.extracted');
441 441
 
442 442
         self::$freadStack = [
443
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
444
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
443
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
444
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
445 445
             '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum',
446 446
             'lorem ipsum</tw-passagedata></tw-storydata>',
447 447
         ];
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
             ->willReturn('readable.extracted');
477 477
 
478 478
         self::$freadStack = [
479
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
480
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
479
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
480
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
481 481
             '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum',
482 482
             'lorem ipsum</tw-passagedata></tw-storydata>',
483 483
         ];
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
             ->willReturn('readable.extracted');
515 515
 
516 516
         self::$freadStack = [
517
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
518
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
517
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
518
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
519 519
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId" position="104,30">lorem ipsum',
520 520
             'lorem ipsum</tw-passagedata>',
521 521
             '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId" position="104,30">lorem ipsum',
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
             ->willReturn('readable.extracted');
549 549
 
550 550
         self::$freadStack = [
551
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
552
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
551
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
552
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
553 553
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
554 554
             'lorem ipsum</tw-passagedata>',
555 555
             '</tw-storydata>',
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
             ->method('save')
582 582
             ->willReturnCallback(function ($textnode) {
583 583
                 static $counter = 0;
584
-                $textnode->setId('someTextnode'.$counter++);
584
+                $textnode->setId('someTextnode' . $counter++);
585 585
             });
586 586
 
587 587
         $returnValue = $this->importTwine->run($importfile);
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
             ->willReturn('readable.extracted');
605 605
 
606 606
         self::$freadStack = [
607
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
608
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
607
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
608
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
609 609
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
610 610
             'lorem ipsum</tw-passagedata>',
611 611
             '</tw-storydata>',
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
             ->method('save')
635 635
             ->willReturnCallback(function ($textnode) {
636 636
                 static $counter = 0;
637
-                $textnode->setId('someTextnode'.$counter++);
637
+                $textnode->setId('someTextnode' . $counter++);
638 638
             });
639 639
 
640 640
         $returnValue = $this->importTwine->run($importfile);
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
             ->willReturn('readable.extracted');
658 658
 
659 659
         self::$freadStack = [
660
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
661
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
660
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
661
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
662 662
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
663 663
             'lorem ipsum</tw-passagedata>',
664 664
             '</tw-storydata>',
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
             ->method('save')
688 688
             ->willReturnCallback(function ($textnode) {
689 689
                 static $counter = 0;
690
-                $textnode->setId('someTextnode'.$counter++);
690
+                $textnode->setId('someTextnode' . $counter++);
691 691
             });
692 692
 
693 693
         $returnValue = $this->importTwine->run($importfile);
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
             ->willReturn('readable.extracted');
711 711
 
712 712
         self::$freadStack = [
713
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
714
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
713
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
714
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
715 715
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
716 716
             'lorem ipsum</tw-passagedata>',
717 717
             '</tw-storydata>',
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
             ->method('save')
741 741
             ->willReturnCallback(function ($textnode) {
742 742
                 static $counter = 0;
743
-                $textnode->setId('someTextnode'.$counter++);
743
+                $textnode->setId('someTextnode' . $counter++);
744 744
             });
745 745
 
746 746
         $returnValue = $this->importTwine->run($importfile);
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
             ->willReturn('readable.extracted');
764 764
 
765 765
         self::$freadStack = [
766
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
767
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
766
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
767
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
768 768
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
769 769
             'lorem ipsum</tw-passagedata>',
770 770
             '</tw-storydata>',
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
             ->method('save')
783 783
             ->willReturnCallback(function ($textnode) {
784 784
                 static $counter = 0;
785
-                $textnode->setId('someTextnode'.$counter++);
785
+                $textnode->setId('someTextnode' . $counter++);
786 786
             });
787 787
 
788 788
         $returnValue = $this->importTwine->run($importfile);
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
             ->willReturn('readable.extracted');
805 805
 
806 806
         self::$freadStack = [
807
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
808
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
807
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
808
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
809 809
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
810 810
             'lorem ipsum</tw-passagedata>',
811 811
             '</tw-storydata>',
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
             ->method('save')
850 850
             ->willReturnCallback(function ($textnode) {
851 851
                 static $counter = 0;
852
-                $textnode->setId('someTextnode'.$counter++);
852
+                $textnode->setId('someTextnode' . $counter++);
853 853
             });
854 854
 
855 855
         $returnValue = $this->importTwine->run($importfile);
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
             ->willReturn('readable.extracted');
872 872
 
873 873
         self::$freadStack = [
874
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
875
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
874
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
875
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
876 876
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
877 877
             'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
878 878
             '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
@@ -913,8 +913,8 @@  discard block
 block discarded – undo
913 913
             ->willReturn('readable.extracted');
914 914
 
915 915
         self::$freadStack = [
916
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
917
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
916
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
917
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
918 918
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
919 919
             'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
920 920
             '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
             ->willReturn('readable.extracted');
951 951
 
952 952
         self::$freadStack = [
953
-            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>'."\n",
954
-            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n",
953
+            '<tw-storydata name="someStoryName" startnode="1" creator="Twine" creator-version="2.0.8" ifid="8E30D51C-4980-4161-B57F-B11C752E879A" format="Harlowe" options=""><style role="stylesheet" id="twine-user-stylesheet" type="text/twine-css"></style>' . "\n",
954
+            '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n",
955 955
             '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum',
956 956
             'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>',
957 957
             '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum',
Please login to merge, or discard this patch.
www/src/AdminBundle/Model/ImportTwine.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $fileHandler = fopen($filenameExtracted, "rb");
123 123
 
124 124
         if ($fileHandler === false) {
125
-            throw new Exception("Couldn't open file '".$this->importfile->getFilename()."'");
125
+            throw new Exception("Couldn't open file '" . $this->importfile->getFilename() . "'");
126 126
         }
127 127
 
128 128
         $this->xmlParser = xml_parser_create("UTF-8");
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             $errorCode = xml_get_error_code($this->xmlParser);
164 164
             $errorDescription = xml_error_string($errorCode);
165 165
 
166
-            throw new Exception("Error #".$errorCode.": '".$errorDescription."' occurred while the envelope head for the Twine archive was parsed.");
166
+            throw new Exception("Error #" . $errorCode . ": '" . $errorDescription . "' occurred while the envelope head for the Twine archive was parsed.");
167 167
         }
168 168
     }
169 169
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             $errorCode = xml_get_error_code($this->xmlParser);
174 174
             $errorDescription = xml_error_string($errorCode);
175 175
 
176
-            throw new Exception("Error #".$errorCode.": '".$errorDescription."' occurred while the envelope foot for the Twine archive was parsed.");
176
+            throw new Exception("Error #" . $errorCode . ": '" . $errorDescription . "' occurred while the envelope foot for the Twine archive was parsed.");
177 177
         }
178 178
     }
179 179
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                 $errorColumnNumber = xml_get_current_column_number($this->xmlParser);
197 197
                 $errorByteIndex = xml_get_current_byte_index($this->xmlParser);
198 198
 
199
-                throw new Exception("Error #".$errorCode.": '".$errorDescription."' occurred while parsing the Twine archive file '".$this->importfile->getFilename()."' in line ".$errorRowNumber.", character ".$errorColumnNumber." (at byte index ".$errorByteIndex.").");
199
+                throw new Exception("Error #" . $errorCode . ": '" . $errorDescription . "' occurred while parsing the Twine archive file '" . $this->importfile->getFilename() . "' in line " . $errorRowNumber . ", character " . $errorColumnNumber . " (at byte index " . $errorByteIndex . ").");
200 200
             }
201 201
         } while (feof($fileHandler) === false);
202 202
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     private function startElementStoryData(string $name, array $attrs): void
221 221
     {
222 222
         if ($this->twineRelevant === true) {
223
-            throw new Exception("Nested '".$name."' found in Twine archive file '".$this->importfile->getFilename()."'.");
223
+            throw new Exception("Nested '" . $name . "' found in Twine archive file '" . $this->importfile->getFilename() . "'.");
224 224
         }
225 225
 
226 226
         if (isset($attrs['startnode']) !== true) {
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         }
233 233
 
234 234
         if (isset($attrs['name']) !== true) {
235
-            throw new Exception("There is a '".$name."' in the Twine archive file '".$this->importfile->getFilename()."' which is missing its 'name' attribute.");
235
+            throw new Exception("There is a '" . $name . "' in the Twine archive file '" . $this->importfile->getFilename() . "' which is missing its 'name' attribute.");
236 236
         }
237 237
 
238 238
         $this->twineStartnodeId = $attrs['startnode'];
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     private function getTwineId(string $tagString, string $textnodeTitle): string
244 244
     {
245 245
         if (empty($tagString) || !is_string($tagString)) {
246
-            throw new Exception('no ID given for Textnode "'.$textnodeTitle.'"');
246
+            throw new Exception('no ID given for Textnode "' . $textnodeTitle . '"');
247 247
         }
248 248
         $tagArray = explode(' ', $tagString);
249 249
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         }
257 257
 
258 258
         if ($twineId === false) {
259
-            throw new Exception('no ID given for Textnode "'.$textnodeTitle.'"');
259
+            throw new Exception('no ID given for Textnode "' . $textnodeTitle . '"');
260 260
         }
261 261
 
262 262
         return $twineId;
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
     private function startElementPassageData(string $name, array $attrs): void
266 266
     {
267 267
         if ($this->twineText !== false) {
268
-            throw new Exception("Nested '".$name."' found in Twine archive file '".$this->importfile->getFilename()."'.");
268
+            throw new Exception("Nested '" . $name . "' found in Twine archive file '" . $this->importfile->getFilename() . "'.");
269 269
         }
270 270
 
271 271
         if (isset($attrs['pid']) !== true) {
272
-            throw new Exception("There is a '".$name."' in the Twine archive file '".$this->importfile->getFilename()."' which is missing its 'pid' attribute.");
272
+            throw new Exception("There is a '" . $name . "' in the Twine archive file '" . $this->importfile->getFilename() . "' which is missing its 'pid' attribute.");
273 273
         }
274 274
 
275 275
         if (is_numeric($attrs['pid']) !== true) {
276
-            throw new Exception("There is a '".$name."' in the Twine archive file '".$this->importfile->getFilename()."' which hasn't a numeric value in its 'pid' attribute ('".$attrs['pid']."' was found instead).");
276
+            throw new Exception("There is a '" . $name . "' in the Twine archive file '" . $this->importfile->getFilename() . "' which hasn't a numeric value in its 'pid' attribute ('" . $attrs['pid'] . "' was found instead).");
277 277
         }
278 278
 
279 279
         $this->twineId = $this->getTwineId($attrs['tags'], $attrs['name']);
280 280
 
281 281
         if (array_key_exists($this->twineId, $this->textnodeMapping) === true) {
282
-            throw new Exception("There is a '".$name."' in the Twine archive file '".$this->importfile->getFilename()."' which has a non unique 'id' tag [".$this->twineId."], in node '".$attrs['name']."'");
282
+            throw new Exception("There is a '" . $name . "' in the Twine archive file '" . $this->importfile->getFilename() . "' which has a non unique 'id' tag [" . $this->twineId . "], in node '" . $attrs['name'] . "'");
283 283
         }
284 284
 
285 285
         $this->twineTextnodeName = $attrs['name'];
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                 $this->textnode->setAccess(true);
312 312
                 $this->accessSet = true;
313 313
             } else {
314
-                throw new Exception('There is more than one \''.$name.'\' in the Twine archive file \''.$this->importfile->getFilename().'\' with the startnode value \''.$attrs['pid'].'\' in its \'pid\' attribute.');
314
+                throw new Exception('There is more than one \'' . $name . '\' in the Twine archive file \'' . $this->importfile->getFilename() . '\' with the startnode value \'' . $attrs['pid'] . '\' in its \'pid\' attribute.');
315 315
             }
316 316
         } else {
317 317
             $this->textnode->setAccess(false);
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     private function characterData($parser, string $data)
333 333
     {
334 334
         if ($this->twineRelevant === true && $this->twineText === true) {
335
-            $this->textnode->setText($this->textnode->getText().$data);
335
+            $this->textnode->setText($this->textnode->getText() . $data);
336 336
         }
337 337
     }
338 338
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     {
341 341
         $textnodeTextNew = preg_replace_callback(
342 342
             '/\[\[(.*?)\]\]/',
343
-            function($matches) use ($textnode, $name) {
343
+            function ($matches) use ($textnode, $name) {
344 344
                 $content = $matches[1];
345 345
                 $hitch = null;
346 346
                 $metadata = null;
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
         $textnode = $this->textnodeRepository->find($dembeloId);
376 376
 
377 377
         if (null === $textnode) {
378
-            throw new Exception('The Dembelo Textnode with Id \''.$dembeloId.'\' doesn\'t exist, but should by now.');
378
+            throw new Exception('The Dembelo Textnode with Id \'' . $dembeloId . '\' doesn\'t exist, but should by now.');
379 379
         }
380 380
 
381 381
         $textnodeText = $textnode->getText();
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
      * @param array|null $hitch
395 395
      * @throws Exception
396 396
      */
397
-    private function appendHitchToTextnode(Textnode $textnode, ?array $hitch): void
397
+    private function appendHitchToTextnode(Textnode $textnode, ? array $hitch) : void
398 398
     {
399 399
         if ($hitch === null) {
400 400
             return;
401 401
         }
402 402
         if ($textnode->getHitchCount() >= Textnode::HITCHES_MAXIMUM_COUNT) {
403
-            throw new Exception('There is a textnode in the Twine archive file which has more than '.Textnode::HITCHES_MAXIMUM_COUNT.' links.');
403
+            throw new Exception('There is a textnode in the Twine archive file which has more than ' . Textnode::HITCHES_MAXIMUM_COUNT . ' links.');
404 404
         }
405 405
 
406 406
         if ($textnode->appendHitch($hitch) !== true) {
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         $contentArray = explode(">:<", $content, 2);
421 421
 
422 422
         if (strlen($contentArray[0]) <= 0 || strlen($contentArray[1]) <= 0) {
423
-            throw new Exception("The Twine archive file contains a '".$name."' with the invalid element '[[".$contentArray[0].">:<".$contentArray[1]."]]'.");
423
+            throw new Exception("The Twine archive file contains a '" . $name . "' with the invalid element '[[" . $contentArray[0] . ">:<" . $contentArray[1] . "]]'.");
424 424
         }
425 425
 
426 426
         $metadata = $textnode->getMetadata();
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
         }
431 431
 
432 432
         if (array_key_exists($contentArray[0], $metadata) === true) {
433
-            throw new Exception("There is a textnode in the Twine archive file which contains the metadata field '".$contentArray[0]."' twice or would overwrite the already existing value of that field.");
433
+            throw new Exception("There is a textnode in the Twine archive file which contains the metadata field '" . $contentArray[0] . "' twice or would overwrite the already existing value of that field.");
434 434
         }
435 435
 
436 436
         $metadata[$contentArray[0]] = $contentArray[1];
Please login to merge, or discard this patch.