@@ -97,7 +97,7 @@ |
||
97 | 97 | /** |
98 | 98 | * import a single file into a collection |
99 | 99 | * |
100 | - * @param SplFileInfo $file file |
|
100 | + * @param \SplFileInfo $file file |
|
101 | 101 | * @param InputInterface $input User input on console |
102 | 102 | * @param OutputInterface $output Output of the command |
103 | 103 | * |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $clientMock = $this->getMockBuilder('\MongoClient')->disableOriginalConstructor()->getMock(); |
52 | 52 | |
53 | 53 | $collection = $this->getMockBuilder('\MongoCollection')->disableOriginalConstructor()->getMock(); |
54 | - $collection->method('save')->will($this->returnCallback(array($this,'saveCollectionCallback'))); |
|
54 | + $collection->method('save')->will($this->returnCallback(array($this, 'saveCollectionCallback'))); |
|
55 | 55 | $clientMock->method('selectCollection')->willReturn($collection); |
56 | 56 | |
57 | 57 | $sut = new CoreImportCommand( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | // fail in output? |
114 | 114 | $this->assertContains( |
115 | - 'Could not deserialize file <' . $this->sourceDir . '/Dudess/Invalid.json>', |
|
115 | + 'Could not deserialize file <'.$this->sourceDir.'/Dudess/Invalid.json>', |
|
116 | 116 | $this->cmdTester->getDisplay() |
117 | 117 | ); |
118 | 118 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * @param SplFileInfo $file |
53 | 53 | * @return bool |
54 | 54 | */ |
55 | - $filter = function (SplFileInfo $file) { |
|
56 | - if (!in_array($file->getExtension(), ['yml','json']) || $file->isDir()) { |
|
55 | + $filter = function(SplFileInfo $file) { |
|
56 | + if (!in_array($file->getExtension(), ['yml', 'json']) || $file->isDir()) { |
|
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | return true; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | try { |
65 | 65 | $this->doImport($finder, $input, $output); |
66 | 66 | } catch (MissingTargetException $e) { |
67 | - $output->writeln('<error>' . $e->getMessage() . '</error>'); |
|
67 | + $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | $responseMock |
52 | 52 | ->method('getHeader') |
53 | 53 | ->with('Link') |
54 | - ->willReturn(['<' . $host . $path . '>; rel="self"']); |
|
54 | + ->willReturn(['<'.$host.$path.'>; rel="self"']); |
|
55 | 55 | |
56 | 56 | $promiseMock |
57 | 57 | ->method('then') |
58 | 58 | ->will( |
59 | 59 | $this->returnCallback( |
60 | - function ($ok) use ($responseMock) { |
|
60 | + function($ok) use ($responseMock) { |
|
61 | 61 | $ok($responseMock); |
62 | 62 | } |
63 | 63 | ) |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | |
75 | 75 | $cmdTester = $this->getTester($sut, $file); |
76 | 76 | |
77 | - $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay()); |
|
78 | - $this->assertContains('Wrote <' . $host . $path . '>; rel="self"', $cmdTester->getDisplay()); |
|
77 | + $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay()); |
|
78 | + $this->assertContains('Wrote <'.$host.$path.'>; rel="self"', $cmdTester->getDisplay()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | return [ |
87 | 87 | 'basic valid file' => [ |
88 | 88 | 'http://localhost', |
89 | - __DIR__ . '/fixtures/set-01/test-2.json', |
|
89 | + __DIR__.'/fixtures/set-01/test-2.json', |
|
90 | 90 | '/core/app/test', |
91 | 91 | ], |
92 | 92 | ]; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return [ |
101 | 101 | 'basic valid image file' => [ |
102 | 102 | 'http://localhost', |
103 | - __DIR__ . '/fixtures/file', |
|
103 | + __DIR__.'/fixtures/file', |
|
104 | 104 | '/core/app/test', |
105 | 105 | ], |
106 | 106 | ]; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $requestMock = $this->getMock('Psr\Http\Message\RequestInterface'); |
135 | 135 | $requestMock |
136 | 136 | ->method('getUri') |
137 | - ->willReturn($host . '/core/app/test'); |
|
137 | + ->willReturn($host.'/core/app/test'); |
|
138 | 138 | |
139 | 139 | $exceptionMock = $this->getMockBuilder('GuzzleHttp\Exception\RequestException') |
140 | 140 | ->setConstructorArgs(['Client error: 400', $requestMock, $responseMock]) |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ->method('then') |
153 | 153 | ->will( |
154 | 154 | $this->returnCallback( |
155 | - function ($ok, $nok) use ($exceptionMock) { |
|
155 | + function($ok, $nok) use ($exceptionMock) { |
|
156 | 156 | return $nok($exceptionMock); |
157 | 157 | } |
158 | 158 | ) |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $cmdTester = $this->getTester($sut, $file); |
171 | 171 | |
172 | - $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay()); |
|
172 | + $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay()); |
|
173 | 173 | foreach ($errors as $error) { |
174 | 174 | $this->assertContains( |
175 | 175 | $error, |
@@ -186,18 +186,18 @@ discard block |
||
186 | 186 | return [ |
187 | 187 | 'invalid file (server side)' => [ |
188 | 188 | 'http://localhost', |
189 | - __DIR__ . '/fixtures/set-01/test.json', |
|
189 | + __DIR__.'/fixtures/set-01/test.json', |
|
190 | 190 | [ |
191 | - 'Failed to write <http://localhost/core/app/test> from \'' . |
|
192 | - __DIR__ . '/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
191 | + 'Failed to write <http://localhost/core/app/test> from \''. |
|
192 | + __DIR__.'/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
193 | 193 | '"message": "invalid"', |
194 | 194 | ], |
195 | 195 | ], |
196 | 196 | 'missing target in file (user error)' => [ |
197 | 197 | 'http://localhost', |
198 | - __DIR__ . '/fixtures/set-01/test-3.json', |
|
198 | + __DIR__.'/fixtures/set-01/test-3.json', |
|
199 | 199 | [ |
200 | - 'Missing target in \'' . __DIR__ . '/fixtures/set-01/test-3.json\'', |
|
200 | + 'Missing target in \''.__DIR__.'/fixtures/set-01/test-3.json\'', |
|
201 | 201 | ], |
202 | 202 | ] |
203 | 203 | ]; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | ->method('then') |
235 | 235 | ->will( |
236 | 236 | $this->returnCallback( |
237 | - function ($ok) use ($responseMock) { |
|
237 | + function($ok) use ($responseMock) { |
|
238 | 238 | $ok($responseMock); |
239 | 239 | } |
240 | 240 | ) |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | $cmdTester = $this->getTester( |
253 | 253 | $sut, |
254 | - __DIR__ . '/fixtures/set-01/test-4.json', |
|
254 | + __DIR__.'/fixtures/set-01/test-4.json', |
|
255 | 255 | [ |
256 | 256 | 'host' => 'http://example.com', |
257 | 257 | '--rewrite-host' => 'http://localhost' |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param string $rewriteTo string to replace value from $rewriteHost with during loading |
212 | 212 | * @param boolean $sync send requests syncronously |
213 | 213 | * |
214 | - * @return Promise\Promise|null |
|
214 | + * @return Promise\PromiseInterface |
|
215 | 215 | */ |
216 | 216 | protected function importResource( |
217 | 217 | $targetUrl, |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @param Document $doc Data source for import data |
332 | 332 | * @param string $originFile Original full filename used toimport |
333 | - * @return bool|mixed |
|
333 | + * @return false|string |
|
334 | 334 | */ |
335 | 335 | private function validateUploadFile(Document $doc, $originFile) |
336 | 336 | { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $output->writeln("<info>Loading data from ${file}</info>"); |
178 | 178 | |
179 | 179 | if (!array_key_exists('target', $doc->getData())) { |
180 | - throw new MissingTargetException('Missing target in \'' . $file . '\''); |
|
180 | + throw new MissingTargetException('Missing target in \''.$file.'\''); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | $targetUrl = sprintf('%s%s', $host, $doc->getData()['target']); |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | $content = str_replace($rewriteHost, $rewriteTo, $doc->getContent()); |
227 | 227 | $uploadFile = $this->validateUploadFile($doc, $file); |
228 | 228 | |
229 | - $successFunc = function (ResponseInterface $response) use ($output) { |
|
229 | + $successFunc = function(ResponseInterface $response) use ($output) { |
|
230 | 230 | $output->writeln( |
231 | - '<comment>Wrote ' . $response->getHeader('Link')[0] . '</comment>' |
|
231 | + '<comment>Wrote '.$response->getHeader('Link')[0].'</comment>' |
|
232 | 232 | ); |
233 | 233 | }; |
234 | 234 | |
235 | - $errFunc = function (RequestException $e) use ($output, $file) { |
|
235 | + $errFunc = function(RequestException $e) use ($output, $file) { |
|
236 | 236 | $output->writeln( |
237 | - '<error>' . str_pad( |
|
237 | + '<error>'.str_pad( |
|
238 | 238 | sprintf( |
239 | 239 | 'Failed to write <%s> from \'%s\' with message \'%s\'', |
240 | 240 | $e->getRequest()->getUri(), |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | ), |
244 | 244 | 140, |
245 | 245 | ' ' |
246 | - ) . '</error>' |
|
246 | + ).'</error>' |
|
247 | 247 | ); |
248 | 248 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
249 | 249 | $this->dumper->dump( |
250 | 250 | $this->cloner->cloneVar( |
251 | 251 | $this->parser->parse($e->getResponse()->getBody(), false, false, true) |
252 | 252 | ), |
253 | - function ($line, $depth) use ($output) { |
|
253 | + function($line, $depth) use ($output) { |
|
254 | 254 | if ($depth > 0) { |
255 | 255 | $output->writeln( |
256 | - '<error>' . str_pad(str_repeat(' ', $depth) . $line, 140, ' ') . '</error>' |
|
256 | + '<error>'.str_pad(str_repeat(' ', $depth).$line, 140, ' ').'</error>' |
|
257 | 257 | ); |
258 | 258 | } |
259 | 259 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | } |
342 | 342 | |
343 | 343 | // Find file |
344 | - $fileName = dirname($originFile) . DIRECTORY_SEPARATOR . $documentData['file']; |
|
344 | + $fileName = dirname($originFile).DIRECTORY_SEPARATOR.$documentData['file']; |
|
345 | 345 | $fileName = str_replace('//', '/', $fileName); |
346 | 346 | if (!file_exists($fileName)) { |
347 | 347 | return false; |