Passed
Push — master ( 087e08...47cc72 )
by Michael
01:46
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
 }
Please login to merge, or discard this patch.
www/src/AdminBundle/Tests/Service/TwineImport/FileCheckTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     {
51 51
         $tmpName = @tempnam('/tmp/phpunit', 'filecheck');
52 52
         $fileHandler = fopen($tmpName, 'r+');
53
-        fwrite($fileHandler, '  '."\n".'<tw-storydata hurz');
53
+        fwrite($fileHandler, '  ' . "\n" . '<tw-storydata hurz');
54 54
         fseek($fileHandler, 0);
55 55
 
56 56
         $fileCheck = new FileCheck();
Please login to merge, or discard this patch.
www/src/DembeloMain/Document/Textnode.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@
 block discarded – undo
228 228
      *
229 229
      * @return array
230 230
      */
231
-    public function getMetadata(): ?array
231
+    public function getMetadata(): ? array
232 232
     {
233 233
         return $this->metadata;
234 234
     }
Please login to merge, or discard this patch.
www/src/AdminBundle/Service/TwineImport/PassageDataParser.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
     public function startElement(string $name, array $attrs): void
65 65
     {
66 66
         if ($this->parserContext->isTwineText()) {
67
-            throw new \Exception("Nested '".$name."' found in Twine archive file '".$this->parserContext->getFilename()."'.");
67
+            throw new \Exception("Nested '" . $name . "' found in Twine archive file '" . $this->parserContext->getFilename() . "'.");
68 68
         }
69 69
 
70 70
         if (isset($attrs['pid']) !== true) {
71
-            throw new \Exception("There is a '".$name."' in the Twine archive file '".$this->parserContext->getFilename()."' which is missing its 'pid' attribute.");
71
+            throw new \Exception("There is a '" . $name . "' in the Twine archive file '" . $this->parserContext->getFilename() . "' which is missing its 'pid' attribute.");
72 72
         }
73 73
 
74 74
         if (is_numeric($attrs['pid']) !== true) {
75
-            throw new \Exception("There is a '".$name."' in the Twine archive file '".$this->parserContext->getFilename()."' which hasn't a numeric value in its 'pid' attribute ('".$attrs['pid']."' was found instead).");
75
+            throw new \Exception("There is a '" . $name . "' in the Twine archive file '" . $this->parserContext->getFilename() . "' which hasn't a numeric value in its 'pid' attribute ('" . $attrs['pid'] . "' was found instead).");
76 76
         }
77 77
 
78 78
         $twineId = $this->getTwineId($attrs['tags'], $attrs['name']);
79 79
 
80 80
         if (array_key_exists($twineId, $this->parserContext->getTextnodeMapping()) === true) {
81
-            throw new \Exception("There is a '".$name."' in the Twine archive file '".$this->parserContext->getFilename()."' which has a non unique 'id' tag [".$twineId."], in node '".$attrs['name']."'");
81
+            throw new \Exception("There is a '" . $name . "' in the Twine archive file '" . $this->parserContext->getFilename() . "' which has a non unique 'id' tag [" . $twineId . "], in node '" . $attrs['name'] . "'");
82 82
         }
83 83
 
84 84
         $textnode = $this->textnodeRepository->findByTwineId($this->parserContext->getImportfile(), $twineId);
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 $textnode->setAccess(true);
103 103
                 $this->parserContext->setAccessSet(true);
104 104
             } else {
105
-                throw new \Exception('There is more than one \''.$name.'\' in the Twine archive file \''.$this->parserContext->getFilename().'\' with the startnode value \''.$attrs['pid'].'\' in its \'pid\' attribute.');
105
+                throw new \Exception('There is more than one \'' . $name . '\' in the Twine archive file \'' . $this->parserContext->getFilename() . '\' with the startnode value \'' . $attrs['pid'] . '\' in its \'pid\' attribute.');
106 106
             }
107 107
         } else {
108 108
             $textnode->setAccess(false);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     private function getTwineId(string $tagString, string $textnodeTitle): string
140 140
     {
141 141
         if (empty($tagString)) {
142
-            throw new \Exception('no ID given for Textnode "'.$textnodeTitle.'"');
142
+            throw new \Exception('no ID given for Textnode "' . $textnodeTitle . '"');
143 143
         }
144 144
         $tagArray = explode(' ', $tagString);
145 145
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
         if ($twineId === false) {
155
-            throw new \Exception('no ID given for Textnode "'.$textnodeTitle.'"');
155
+            throw new \Exception('no ID given for Textnode "' . $textnodeTitle . '"');
156 156
         }
157 157
 
158 158
         return $twineId;
Please login to merge, or discard this patch.
www/src/AdminBundle/Service/TwineImport/StoryDataParser.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $textnode = $this->textnodeRepository->find($dembeloId);
109 109
 
110 110
         if (null === $textnode) {
111
-            throw new \Exception('The Dembelo Textnode with Id \''.$dembeloId.'\' doesn\'t exist, but should by now.');
111
+            throw new \Exception('The Dembelo Textnode with Id \'' . $dembeloId . '\' doesn\'t exist, but should by now.');
112 112
         }
113 113
 
114 114
         $textnodeText = $textnode->getText();
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     private function checkElementStoryData(string $name, array $attributes): bool
126 126
     {
127 127
         if ($this->parserContext->isTwineRelevant()) {
128
-            throw new \Exception("Nested '".$name."' found in Twine archive file '".$this->parserContext->getFilename()."'.");
128
+            throw new \Exception("Nested '" . $name . "' found in Twine archive file '" . $this->parserContext->getFilename() . "'.");
129 129
         }
130 130
 
131 131
         if (!isset($attributes['startnode']) || !is_numeric($attributes['startnode'])) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         }
134 134
 
135 135
         if (isset($attributes['name']) !== true) {
136
-            throw new \Exception("There is a '".$name."' in the Twine archive file '".$this->parserContext->getFilename()."' which is missing its 'name' attribute.");
136
+            throw new \Exception("There is a '" . $name . "' in the Twine archive file '" . $this->parserContext->getFilename() . "' which is missing its 'name' attribute.");
137 137
         }
138 138
 
139 139
         return true;
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
      * @param array|null $hitch
198 198
      * @throws \Exception
199 199
      */
200
-    private function appendHitchToTextnode(Textnode $textnode, ?array $hitch): void
200
+    private function appendHitchToTextnode(Textnode $textnode, ? array $hitch) : void
201 201
     {
202 202
         if ($hitch === null) {
203 203
             return;
204 204
         }
205 205
         if ($textnode->getHitchCount() >= Textnode::HITCHES_MAXIMUM_COUNT) {
206
-            throw new \Exception('There is a textnode in the Twine archive file which has more than '.Textnode::HITCHES_MAXIMUM_COUNT.' links.');
206
+            throw new \Exception('There is a textnode in the Twine archive file which has more than ' . Textnode::HITCHES_MAXIMUM_COUNT . ' links.');
207 207
         }
208 208
 
209 209
         if ($textnode->appendHitch($hitch) !== true) {
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
         $contentArray = explode('>:<', $content, 2);
224 224
 
225 225
         if (strlen($contentArray[0]) <= 0 || strlen($contentArray[1]) <= 0) {
226
-            throw new \Exception('The Twine archive file contains a \''.$name.'\' with the invalid element \'[['.$contentArray[0].'>:<'.$contentArray[1].']]\'.');
226
+            throw new \Exception('The Twine archive file contains a \'' . $name . '\' with the invalid element \'[[' . $contentArray[0] . '>:<' . $contentArray[1] . ']]\'.');
227 227
         }
228 228
 
229 229
         $metadata = $textnode->getMetadata() ?? [];
230 230
 
231 231
         if (array_key_exists($contentArray[0], $metadata) === true) {
232
-            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.');
232
+            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.');
233 233
         }
234 234
 
235 235
         $metadata[$contentArray[0]] = $contentArray[1];
Please login to merge, or discard this patch.
www/src/AdminBundle/Tests/Service/TwineImport/StoryDataParserTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
         $textnodeMock = $this->createMock(Textnode::class);
184 184
         $textnodeMock->expects(self::any())
185 185
             ->method('getText')
186
-            ->willReturn('someText'."\n"."someOtherText ");
186
+            ->willReturn('someText' . "\n" . "someOtherText ");
187 187
         $textnodeMock->expects(self::once())
188 188
             ->method('setText')
189 189
             ->willReturnCallback(function (string $textNew) {
Please login to merge, or discard this patch.