@@ -344,7 +344,7 @@ |
||
| 344 | 344 | * |
| 345 | 345 | * @param Document $doc Data source for import data |
| 346 | 346 | * @param string $originFile Original full filename used toimport |
| 347 | - * @return bool|mixed |
|
| 347 | + * @return false|string |
|
| 348 | 348 | */ |
| 349 | 349 | private function validateUploadFile(Document $doc, $originFile) |
| 350 | 350 | { |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $output->writeln("<info>Loading data from ${file}</info>"); |
| 236 | 236 | |
| 237 | 237 | if (!array_key_exists('target', $doc->getData())) { |
| 238 | - throw new MissingTargetException('Missing target in \'' . $file . '\''); |
|
| 238 | + throw new MissingTargetException('Missing target in \''.$file.'\''); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | $targetUrl = sprintf('%s%s', $host, $doc->getData()['target']); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | // Authentication or custom headers. |
| 285 | 285 | if ($this->headerBasicAuth) { |
| 286 | - $data['headers']['Authorization'] = 'Basic '. base64_encode($this->headerBasicAuth); |
|
| 286 | + $data['headers']['Authorization'] = 'Basic '.base64_encode($this->headerBasicAuth); |
|
| 287 | 287 | } |
| 288 | 288 | if ($this->customHeaders) { |
| 289 | 289 | foreach ($this->customHeaders as $headers) { |
@@ -300,14 +300,14 @@ discard block |
||
| 300 | 300 | $response = $this->client->request('GET', $targetUrl, array_merge($data, ['http_errors' => false])); |
| 301 | 301 | if ($response->getStatusCode() == 200) { |
| 302 | 302 | $output->writeln( |
| 303 | - '<info>' . str_pad( |
|
| 303 | + '<info>'.str_pad( |
|
| 304 | 304 | sprintf( |
| 305 | 305 | 'Skipping <%s> as "no overwrite" is activated and it does exist.', |
| 306 | 306 | $targetUrl |
| 307 | 307 | ), |
| 308 | 308 | 140, |
| 309 | 309 | ' ' |
| 310 | - ) . '</info>' |
|
| 310 | + ).'</info>' |
|
| 311 | 311 | ); |
| 312 | 312 | return; |
| 313 | 313 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | $output->writeln('<info>File deleted: '.$targetUrl.'</info>'); |
| 322 | 322 | } catch (\Exception $e) { |
| 323 | 323 | $output->writeln( |
| 324 | - '<error>' . str_pad( |
|
| 324 | + '<error>'.str_pad( |
|
| 325 | 325 | sprintf( |
| 326 | 326 | 'Failed to delete <%s> with message \'%s\'', |
| 327 | 327 | $targetUrl, |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | ), |
| 330 | 330 | 140, |
| 331 | 331 | ' ' |
| 332 | - ) . '</error>' |
|
| 332 | + ).'</error>' |
|
| 333 | 333 | ); |
| 334 | 334 | } |
| 335 | 335 | } |
@@ -341,12 +341,12 @@ discard block |
||
| 341 | 341 | ); |
| 342 | 342 | |
| 343 | 343 | $output->writeln( |
| 344 | - '<comment>Wrote ' . $response->getHeader('Link')[0] . '</comment>' |
|
| 344 | + '<comment>Wrote '.$response->getHeader('Link')[0].'</comment>' |
|
| 345 | 345 | ); |
| 346 | 346 | } catch (\Exception $e) { |
| 347 | 347 | $this->errors[$file] = $e->getMessage(); |
| 348 | 348 | $output->writeln( |
| 349 | - '<error>' . str_pad( |
|
| 349 | + '<error>'.str_pad( |
|
| 350 | 350 | sprintf( |
| 351 | 351 | 'Failed to write <%s> from \'%s\' with message \'%s\'', |
| 352 | 352 | $e->getRequest()->getUri(), |
@@ -355,17 +355,17 @@ discard block |
||
| 355 | 355 | ), |
| 356 | 356 | 140, |
| 357 | 357 | ' ' |
| 358 | - ) . '</error>' |
|
| 358 | + ).'</error>' |
|
| 359 | 359 | ); |
| 360 | 360 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
| 361 | 361 | $this->dumper->dump( |
| 362 | 362 | $this->cloner->cloneVar( |
| 363 | 363 | $this->parser->parse($e->getResponse()->getBody(), false, false, true) |
| 364 | 364 | ), |
| 365 | - function ($line, $depth) use ($output) { |
|
| 365 | + function($line, $depth) use ($output) { |
|
| 366 | 366 | if ($depth > 0) { |
| 367 | 367 | $output->writeln( |
| 368 | - '<error>' . str_pad(str_repeat(' ', $depth) . $line, 140, ' ') . '</error>' |
|
| 368 | + '<error>'.str_pad(str_repeat(' ', $depth).$line, 140, ' ').'</error>' |
|
| 369 | 369 | ); |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // Find file |
| 425 | - $fileName = dirname($originFile) . DIRECTORY_SEPARATOR . $documentData['file']; |
|
| 425 | + $fileName = dirname($originFile).DIRECTORY_SEPARATOR.$documentData['file']; |
|
| 426 | 426 | $fileName = str_replace('//', '/', $fileName); |
| 427 | 427 | if (!file_exists($fileName)) { |
| 428 | 428 | return false; |
@@ -84,15 +84,15 @@ |
||
| 84 | 84 | protected function execute(InputInterface $input, OutputInterface $output) |
| 85 | 85 | { |
| 86 | 86 | $files = $input->getArgument('file'); |
| 87 | - $finder = new Finder(); |
|
| 87 | + $finder = new Finder(); |
|
| 88 | 88 | $finder = $finder->files(); |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @param SplFileInfo $file |
| 92 | 92 | * @return bool |
| 93 | 93 | */ |
| 94 | - $filter = function (SplFileInfo $file) { |
|
| 95 | - if (!in_array($file->getExtension(), ['yml','json']) || $file->isDir()) { |
|
| 94 | + $filter = function(SplFileInfo $file) { |
|
| 95 | + if (!in_array($file->getExtension(), ['yml', 'json']) || $file->isDir()) { |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | return true; |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | use Graviton\ImportExport\Util\JsonSerializer; |
| 9 | 9 | use Symfony\Component\Console\Command\Command; |
| 10 | 10 | use Symfony\Component\Console\Input\InputArgument; |
| 11 | - |
|
| 12 | 11 | use Symfony\Component\Console\Input\InputInterface; |
| 13 | 12 | use Symfony\Component\Console\Input\InputOption; |
| 14 | 13 | use Symfony\Component\Console\Output\OutputInterface; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $clientMock = $this->getMockBuilder('\MongoClient')->disableOriginalConstructor()->getMock(); |
| 52 | 52 | |
| 53 | 53 | $collectionMock = $this->getMockBuilder('\MongoCollection')->disableOriginalConstructor()->getMock(); |
| 54 | - $collectionMock->method('save')->will($this->returnCallback(array($this,'saveCollectionCallback'))); |
|
| 54 | + $collectionMock->method('save')->will($this->returnCallback(array($this, 'saveCollectionCallback'))); |
|
| 55 | 55 | |
| 56 | 56 | $dbMock = $this->getMockBuilder('\MongoDB')->disableOriginalConstructor()->getMock(); |
| 57 | 57 | $dbMock->method('selectCollection')->willReturn($collectionMock); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | // fail in output? |
| 128 | 128 | $this->assertContains( |
| 129 | - 'Error in <' . $this->sourceDir . '/Dudess/Invalid.json>: Invalid JSON to unserialize.', |
|
| 129 | + 'Error in <'.$this->sourceDir.'/Dudess/Invalid.json>: Invalid JSON to unserialize.', |
|
| 130 | 130 | $this->cmdTester->getDisplay() |
| 131 | 131 | ); |
| 132 | 132 | $this->assertEquals(1, $this->cmdTester->getStatusCode()); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $responseMock |
| 46 | 46 | ->method('getHeader') |
| 47 | 47 | ->with('Link') |
| 48 | - ->willReturn(['<' . $host . $path . '>; rel="self"']); |
|
| 48 | + ->willReturn(['<'.$host.$path.'>; rel="self"']); |
|
| 49 | 49 | |
| 50 | 50 | $clientMock |
| 51 | 51 | ->method('request') |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $cmdTester = $this->getTester($sut, $file); |
| 64 | 64 | |
| 65 | - $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay()); |
|
| 66 | - $this->assertContains('Wrote <' . $host . $path . '>; rel="self"', $cmdTester->getDisplay()); |
|
| 65 | + $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay()); |
|
| 66 | + $this->assertContains('Wrote <'.$host.$path.'>; rel="self"', $cmdTester->getDisplay()); |
|
| 67 | 67 | $this->assertEquals(0, $cmdTester->getStatusCode()); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | return [ |
| 76 | 76 | 'basic valid file' => [ |
| 77 | 77 | 'http://localhost', |
| 78 | - __DIR__ . '/fixtures/set-01/test-2.json', |
|
| 78 | + __DIR__.'/fixtures/set-01/test-2.json', |
|
| 79 | 79 | '/core/app/test', |
| 80 | 80 | ], |
| 81 | 81 | 'basic valid image file' => [ |
| 82 | 82 | 'http://localhost', |
| 83 | - __DIR__ . '/fixtures/file', |
|
| 83 | + __DIR__.'/fixtures/file', |
|
| 84 | 84 | '/core/app/test', |
| 85 | 85 | ], |
| 86 | 86 | ]; |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | $responseMock |
| 108 | 108 | ->method('getHeader') |
| 109 | 109 | ->with('Link') |
| 110 | - ->willReturn(['<' . $host . $file . '>; rel="self"']); |
|
| 110 | + ->willReturn(['<'.$host.$file.'>; rel="self"']); |
|
| 111 | 111 | |
| 112 | 112 | $requestMock = $this->createMock('Psr\Http\Message\RequestInterface'); |
| 113 | 113 | $requestMock |
| 114 | 114 | ->method('getUri') |
| 115 | - ->willReturn($host . '/core/app/test'); |
|
| 115 | + ->willReturn($host.'/core/app/test'); |
|
| 116 | 116 | |
| 117 | 117 | $exceptionMock = $this->getMockBuilder('GuzzleHttp\Exception\RequestException') |
| 118 | 118 | ->setConstructorArgs(['Client error: 400', $requestMock, $responseMock]) |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | $cmdTester = $this->getTester($sut, $file); |
| 143 | 143 | |
| 144 | - $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay()); |
|
| 144 | + $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay()); |
|
| 145 | 145 | foreach ($errors as $error) { |
| 146 | 146 | $this->assertContains( |
| 147 | 147 | $error, |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | return [ |
| 160 | 160 | 'invalid file (server side)' => [ |
| 161 | 161 | 'http://localhost', |
| 162 | - __DIR__ . '/fixtures/set-01/test.json', |
|
| 162 | + __DIR__.'/fixtures/set-01/test.json', |
|
| 163 | 163 | [ |
| 164 | - 'Failed to write <http://localhost/core/app/test> from \'' . |
|
| 165 | - __DIR__ . '/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
| 164 | + 'Failed to write <http://localhost/core/app/test> from \''. |
|
| 165 | + __DIR__.'/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
| 166 | 166 | '"message": "invalid"', |
| 167 | 167 | ], |
| 168 | 168 | ], |
| 169 | 169 | 'missing target in file (user error)' => [ |
| 170 | 170 | 'http://localhost', |
| 171 | - __DIR__ . '/fixtures/set-01/test-3.json', |
|
| 171 | + __DIR__.'/fixtures/set-01/test-3.json', |
|
| 172 | 172 | [ |
| 173 | - 'Missing target in \'' . __DIR__ . '/fixtures/set-01/test-3.json\'', |
|
| 173 | + 'Missing target in \''.__DIR__.'/fixtures/set-01/test-3.json\'', |
|
| 174 | 174 | ], |
| 175 | 175 | ] |
| 176 | 176 | ]; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | $cmdTester = $this->getTester( |
| 219 | 219 | $sut, |
| 220 | - __DIR__ . '/fixtures/set-01/test-4.json', |
|
| 220 | + __DIR__.'/fixtures/set-01/test-4.json', |
|
| 221 | 221 | [ |
| 222 | 222 | 'host' => 'http://example.com', |
| 223 | 223 | '--rewrite-host' => 'http://localhost' |