@@ -45,7 +45,7 @@ |
||
| 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 |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | self::$freadStack = [ |
| 237 | 237 | '<tw-storydata ', |
| 238 | - '<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", |
|
| 239 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 238 | + '<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", |
|
| 239 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 240 | 240 | '<tw-passagedata pid="1" name="someNodeName" tags="Freigegeben ID:foobar" position="104,30">lorem impsum', |
| 241 | 241 | 'lorem impsum</tw-passagedata></tw-storydata>', |
| 242 | 242 | ]; |
@@ -273,8 +273,8 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | self::$freadStack = [ |
| 275 | 275 | '<tw-storydata ', |
| 276 | - '<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", |
|
| 277 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 276 | + '<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", |
|
| 277 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 278 | 278 | '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum', |
| 279 | 279 | 'lorem ipsum</tw-passagedata></tw-storydata>', |
| 280 | 280 | ]; |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | self::$freadStack = [ |
| 317 | 317 | '<tw-storydata ', |
| 318 | - '<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", |
|
| 319 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 318 | + '<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", |
|
| 319 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 320 | 320 | '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum', |
| 321 | 321 | 'ein [[kaputter Link</tw-passagedata></tw-storydata>', |
| 322 | 322 | ]; |
@@ -383,8 +383,8 @@ discard block |
||
| 383 | 383 | |
| 384 | 384 | self::$freadStack = [ |
| 385 | 385 | '<tw-storydata ', |
| 386 | - '<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", |
|
| 387 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 386 | + '<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", |
|
| 387 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 388 | 388 | '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben" position="104,30">lorem ipsum', |
| 389 | 389 | 'lorem ipsum</tw-passagedata></tw-storydata>', |
| 390 | 390 | ]; |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | self::$freadStack = [ |
| 417 | 417 | '<tw-storydata ', |
| 418 | - '<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", |
|
| 419 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 418 | + '<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", |
|
| 419 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 420 | 420 | '<tw-passagedata pid="1" name="someNodeName1" tags="" position="104,30">lorem ipsum', |
| 421 | 421 | 'lorem ipsum</tw-passagedata></tw-storydata>', |
| 422 | 422 | ]; |
@@ -447,8 +447,8 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | self::$freadStack = [ |
| 449 | 449 | '<tw-storydata ', |
| 450 | - '<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", |
|
| 451 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 450 | + '<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", |
|
| 451 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 452 | 452 | '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum', |
| 453 | 453 | 'lorem ipsum</tw-passagedata></tw-storydata>', |
| 454 | 454 | ]; |
@@ -482,8 +482,8 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | self::$freadStack = [ |
| 484 | 484 | '<tw-storydata ', |
| 485 | - '<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", |
|
| 486 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 485 | + '<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", |
|
| 486 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 487 | 487 | '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum', |
| 488 | 488 | 'lorem ipsum</tw-passagedata></tw-storydata>', |
| 489 | 489 | ]; |
@@ -519,8 +519,8 @@ discard block |
||
| 519 | 519 | |
| 520 | 520 | self::$freadStack = [ |
| 521 | 521 | '<tw-storydata ', |
| 522 | - '<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", |
|
| 523 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 522 | + '<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", |
|
| 523 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 524 | 524 | '<tw-passagedata pid="1" name="someNodeName1" tags="Freigegeben ID:foobar" position="104,30">lorem ipsum', |
| 525 | 525 | 'lorem ipsum</tw-passagedata></tw-storydata>', |
| 526 | 526 | ]; |
@@ -558,8 +558,8 @@ discard block |
||
| 558 | 558 | |
| 559 | 559 | self::$freadStack = [ |
| 560 | 560 | '<tw-storydata ', |
| 561 | - '<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", |
|
| 562 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 561 | + '<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", |
|
| 562 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 563 | 563 | '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId" position="104,30">lorem ipsum', |
| 564 | 564 | 'lorem ipsum</tw-passagedata>', |
| 565 | 565 | '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId" position="104,30">lorem ipsum', |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | self::$freadStack = [ |
| 595 | 595 | '<tw-storydata ', |
| 596 | - '<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", |
|
| 597 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 596 | + '<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", |
|
| 597 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 598 | 598 | '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum', |
| 599 | 599 | 'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>', |
| 600 | 600 | '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum', |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | ->method('save') |
| 629 | 629 | ->willReturnCallback(function ($textnode) { |
| 630 | 630 | static $counter = 0; |
| 631 | - $textnode->setId('someTextnode'.$counter++); |
|
| 631 | + $textnode->setId('someTextnode' . $counter++); |
|
| 632 | 632 | }); |
| 633 | 633 | |
| 634 | 634 | $returnValue = $this->importTwine->run($importfile); |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | |
| 650 | 650 | self::$freadStack = [ |
| 651 | 651 | '<tw-storydata ', |
| 652 | - '<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", |
|
| 653 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 652 | + '<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", |
|
| 653 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 654 | 654 | '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum', |
| 655 | 655 | 'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>', |
| 656 | 656 | '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum', |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | self::$freadStack = [ |
| 694 | 694 | '<tw-storydata ', |
| 695 | - '<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", |
|
| 696 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 695 | + '<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", |
|
| 696 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 697 | 697 | '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum', |
| 698 | 698 | 'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>', |
| 699 | 699 | '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum', |
@@ -730,8 +730,8 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | self::$freadStack = [ |
| 732 | 732 | '<tw-storydata ', |
| 733 | - '<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", |
|
| 734 | - '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>'."\n", |
|
| 733 | + '<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", |
|
| 734 | + '<script role="script" id="twine-user-script" type="text/twine-javascript"></script>' . "\n", |
|
| 735 | 735 | '<tw-passagedata pid="1" name="someNodeName1" tags="ID:someTwineId1" position="104,30">lorem ipsum', |
| 736 | 736 | 'lorem ipsum [[Linkdata->someNodeName2]]</tw-passagedata>', |
| 737 | 737 | '<tw-passagedata pid="2" name="someNodeName2" tags="ID:someTwineId2" position="104,30">lorem ipsum', |
@@ -32,9 +32,9 @@ |
||
| 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; |
@@ -67,13 +67,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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(); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | $fileHandler = fopen($filenameExtracted, "rb"); |
| 114 | 114 | |
| 115 | 115 | if ($fileHandler === false) { |
| 116 | - throw new Exception("Couldn't open file '".$this->importfile->getFilename()."'"); |
|
| 116 | + throw new Exception("Couldn't open file '" . $this->importfile->getFilename() . "'"); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $this->xmlParser = xml_parser_create("UTF-8"); |
@@ -143,13 +143,13 @@ discard block |
||
| 143 | 143 | $peekData = fread($fileHandler, 1024); |
| 144 | 144 | |
| 145 | 145 | if ($peekData === false) { |
| 146 | - throw new Exception("Failed to read data from file '".$this->importfile->getFilename()."'."); |
|
| 146 | + throw new Exception("Failed to read data from file '" . $this->importfile->getFilename() . "'."); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $peekDataLength = strlen($peekData); |
| 150 | 150 | |
| 151 | 151 | if ($peekDataLength <= 0) { |
| 152 | - throw new Exception("File '".$this->importfile->getFilename()."' seems to be empty."); |
|
| 152 | + throw new Exception("File '" . $this->importfile->getFilename() . "' seems to be empty."); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | for ($i = 0; $i < $peekDataLength; $i++) { |
@@ -162,21 +162,21 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if ($peekDataLength - $i < $magicStringLength) { |
| 165 | - throw new Exception("File '".$this->importfile->getFilename()."' isn't a Twine archive file."); |
|
| 165 | + throw new Exception("File '" . $this->importfile->getFilename() . "' isn't a Twine archive file."); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | if (substr($peekData, $i, $magicStringLength) !== $magicString) { |
| 169 | - throw new Exception("File '".$this->importfile->getFilename()."' isn't a Twine archive file."); |
|
| 169 | + throw new Exception("File '" . $this->importfile->getFilename() . "' isn't a Twine archive file."); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | if (fseek($fileHandler, 0) !== 0) { |
| 173 | - throw new Exception("Couldn't reset reading position after the magic string in the Twine archive file '".$this->importfile->getFilename()."' was checked."); |
|
| 173 | + throw new Exception("Couldn't reset reading position after the magic string in the Twine archive file '" . $this->importfile->getFilename() . "' was checked."); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | return true; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - throw new Exception("File '".$this->importfile->getFilename()."' doesn't seem to be a Twine archive file."); |
|
| 179 | + throw new Exception("File '" . $this->importfile->getFilename() . "' doesn't seem to be a Twine archive file."); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | private function setXmlHandler(): void |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $errorCode = xml_get_error_code($this->xmlParser); |
| 199 | 199 | $errorDescription = xml_error_string($errorCode); |
| 200 | 200 | |
| 201 | - throw new Exception("Error #".$errorCode.": '".$errorDescription."' occurred while the envelope head for the Twine archive was parsed."); |
|
| 201 | + throw new Exception("Error #" . $errorCode . ": '" . $errorDescription . "' occurred while the envelope head for the Twine archive was parsed."); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $errorCode = xml_get_error_code($this->xmlParser); |
| 209 | 209 | $errorDescription = xml_error_string($errorCode); |
| 210 | 210 | |
| 211 | - throw new Exception("Error #".$errorCode.": '".$errorDescription."' occurred while the envelope foot for the Twine archive was parsed."); |
|
| 211 | + throw new Exception("Error #" . $errorCode . ": '" . $errorDescription . "' occurred while the envelope foot for the Twine archive was parsed."); |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $errorColumnNumber = xml_get_current_column_number($this->xmlParser); |
| 232 | 232 | $errorByteIndex = xml_get_current_byte_index($this->xmlParser); |
| 233 | 233 | |
| 234 | - 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.")."); |
|
| 234 | + 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 . ")."); |
|
| 235 | 235 | } |
| 236 | 236 | } while (feof($fileHandler) === false); |
| 237 | 237 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | private function startElementStoryData(string $name, array $attrs): void |
| 256 | 256 | { |
| 257 | 257 | if ($this->twineRelevant === true) { |
| 258 | - throw new Exception("Nested '".$name."' found in Twine archive file '".$this->importfile->getFilename()."'."); |
|
| 258 | + throw new Exception("Nested '" . $name . "' found in Twine archive file '" . $this->importfile->getFilename() . "'."); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | if (isset($attrs['startnode']) !== true) { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if (isset($attrs['name']) !== true) { |
| 270 | - throw new Exception("There is a '".$name."' in the Twine archive file '".$this->importfile->getFilename()."' which is missing its 'name' attribute."); |
|
| 270 | + throw new Exception("There is a '" . $name . "' in the Twine archive file '" . $this->importfile->getFilename() . "' which is missing its 'name' attribute."); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $this->twineStartnodeId = $attrs['startnode']; |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | private function getTwineId(string $tagString, string $textnodeTitle): string |
| 279 | 279 | { |
| 280 | 280 | if (empty($tagString) || !is_string($tagString)) { |
| 281 | - throw new Exception('no ID given for Textnode "'.$textnodeTitle.'"'); |
|
| 281 | + throw new Exception('no ID given for Textnode "' . $textnodeTitle . '"'); |
|
| 282 | 282 | } |
| 283 | 283 | $tagArray = explode(' ', $tagString); |
| 284 | 284 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | if ($twineId === false) { |
| 294 | - throw new Exception('no ID given for Textnode "'.$textnodeTitle.'"'); |
|
| 294 | + throw new Exception('no ID given for Textnode "' . $textnodeTitle . '"'); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | return $twineId; |
@@ -300,21 +300,21 @@ discard block |
||
| 300 | 300 | private function startElementPassageData(string $name, array $attrs): void |
| 301 | 301 | { |
| 302 | 302 | if ($this->twineText !== false) { |
| 303 | - throw new Exception("Nested '".$name."' found in Twine archive file '".$this->importfile->getFilename()."'."); |
|
| 303 | + throw new Exception("Nested '" . $name . "' found in Twine archive file '" . $this->importfile->getFilename() . "'."); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | if (isset($attrs['pid']) !== true) { |
| 307 | - throw new Exception("There is a '".$name."' in the Twine archive file '".$this->importfile->getFilename()."' which is missing its 'pid' attribute."); |
|
| 307 | + throw new Exception("There is a '" . $name . "' in the Twine archive file '" . $this->importfile->getFilename() . "' which is missing its 'pid' attribute."); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | if (is_numeric($attrs['pid']) !== true) { |
| 311 | - 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)."); |
|
| 311 | + 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)."); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | $this->twineId = $this->getTwineId($attrs['tags'], $attrs['name']); |
| 315 | 315 | |
| 316 | 316 | if (array_key_exists($this->twineId, $this->textnodeMapping) === true) { |
| 317 | - 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']."'"); |
|
| 317 | + 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'] . "'"); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $this->twineTextnodeName = $attrs['name']; |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $this->textnode->setAccess(true); |
| 347 | 347 | $this->accessSet = true; |
| 348 | 348 | } else { |
| 349 | - 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.'); |
|
| 349 | + 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.'); |
|
| 350 | 350 | } |
| 351 | 351 | } else { |
| 352 | 352 | $this->textnode->setAccess(false); |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | private function characterData($parser, string $data) |
| 368 | 368 | { |
| 369 | 369 | if ($this->twineRelevant === true && $this->twineText === true) { |
| 370 | - $this->textnode->setText($this->textnode->getText().$data); |
|
| 370 | + $this->textnode->setText($this->textnode->getText() . $data); |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $textnode = $this->textnodeRepository->find($dembeloId); |
| 436 | 436 | |
| 437 | 437 | if (null === $textnode) { |
| 438 | - throw new Exception('The Dembelo Textnode with Id \''.$dembeloId.'\' doesn\'t exist, but should by now.'); |
|
| 438 | + throw new Exception('The Dembelo Textnode with Id \'' . $dembeloId . '\' doesn\'t exist, but should by now.'); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $textnodeText = $textnode->getText(); |
@@ -454,13 +454,13 @@ discard block |
||
| 454 | 454 | * @param array|null $hitch |
| 455 | 455 | * @throws Exception |
| 456 | 456 | */ |
| 457 | - private function appendHitchToTextnode(Textnode $textnode, ?array $hitch): void |
|
| 457 | + private function appendHitchToTextnode(Textnode $textnode, ? array $hitch) : void |
|
| 458 | 458 | { |
| 459 | 459 | if ($hitch === null) { |
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | 462 | if ($textnode->getHitchCount() >= Textnode::HITCHES_MAXIMUM_COUNT) { |
| 463 | - throw new Exception('There is a textnode in the Twine archive file which has more than '.Textnode::HITCHES_MAXIMUM_COUNT.' links.'); |
|
| 463 | + throw new Exception('There is a textnode in the Twine archive file which has more than ' . Textnode::HITCHES_MAXIMUM_COUNT . ' links.'); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | if ($textnode->appendHitch($hitch) !== true) { |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | $contentArray = explode(">:<", $content, 2); |
| 481 | 481 | |
| 482 | 482 | if (strlen($contentArray[0]) <= 0 || strlen($contentArray[1]) <= 0) { |
| 483 | - throw new Exception("The Twine archive file contains a '".$name."' with the invalid element '[[".$contentArray[0].">:<".$contentArray[1]."]]'."); |
|
| 483 | + throw new Exception("The Twine archive file contains a '" . $name . "' with the invalid element '[[" . $contentArray[0] . ">:<" . $contentArray[1] . "]]'."); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $metadata = $textnode->getMetadata(); |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | if (array_key_exists($contentArray[0], $metadata) === true) { |
| 493 | - 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."); |
|
| 493 | + 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."); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $metadata[$contentArray[0]] = $contentArray[1]; |