@@ -5,7 +5,6 @@ |
||
| 5 | 5 | |
| 6 | 6 | namespace Graviton\ImportExport\Command; |
| 7 | 7 | |
| 8 | -use Monolog\Logger; |
|
| 9 | 8 | use Symfony\Component\Console\Input\InputArgument; |
| 10 | 9 | use Symfony\Component\Console\Input\InputInterface; |
| 11 | 10 | use Symfony\Component\Console\Input\InputOption; |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use Graviton\ImportExport\Exception\ParseException; |
| 14 | 14 | use Graviton\ImportExport\Exception\UnknownFileTypeException; |
| 15 | 15 | use Graviton\ImportExport\Service\HttpClient; |
| 16 | -use Monolog\Logger; |
|
| 17 | 16 | use Symfony\Component\Console\Input\InputArgument; |
| 18 | 17 | use Symfony\Component\Console\Input\InputOption; |
| 19 | 18 | use Symfony\Component\Console\Input\InputInterface; |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $this->logger->info("Loading data from ${file}"); |
| 241 | 241 | |
| 242 | 242 | if (!array_key_exists('target', $doc->getData())) { |
| 243 | - throw new MissingTargetException('Missing target in \'' . $file . '\''); |
|
| 243 | + throw new MissingTargetException('Missing target in \''.$file.'\''); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $targetUrl = sprintf('%s%s', $host, $doc->getData()['target']); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | // Authentication or custom headers. |
| 290 | 290 | if ($this->headerBasicAuth) { |
| 291 | - $data['headers']['Authorization'] = 'Basic '. base64_encode($this->headerBasicAuth); |
|
| 291 | + $data['headers']['Authorization'] = 'Basic '.base64_encode($this->headerBasicAuth); |
|
| 292 | 292 | } |
| 293 | 293 | if ($this->customHeaders) { |
| 294 | 294 | foreach ($this->customHeaders as $headers) { |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $targetUrl, |
| 330 | 330 | array_merge($data, ['http_errors' => false]) |
| 331 | 331 | ); |
| 332 | - $this->logger->info("File deleted: ${targetUrl} (response code " . $response->getStatusCode().")"); |
|
| 332 | + $this->logger->info("File deleted: ${targetUrl} (response code ".$response->getStatusCode().")"); |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $data |
| 340 | 340 | ); |
| 341 | 341 | |
| 342 | - $this->logger->info('Wrote ' . $response->getHeader('Link')[0]); |
|
| 342 | + $this->logger->info('Wrote '.$response->getHeader('Link')[0]); |
|
| 343 | 343 | } catch (\Exception $e) { |
| 344 | 344 | $this->errors[$file] = $e->getMessage(); |
| 345 | 345 | $this->logger->error( |
@@ -356,10 +356,10 @@ discard block |
||
| 356 | 356 | $this->cloner->cloneVar( |
| 357 | 357 | $this->parser->parse($e->getResponse()->getBody(), Yaml::PARSE_OBJECT_FOR_MAP) |
| 358 | 358 | ), |
| 359 | - function ($line, $depth) use ($output) { |
|
| 359 | + function($line, $depth) use ($output) { |
|
| 360 | 360 | if ($depth > 0) { |
| 361 | 361 | $output->writeln( |
| 362 | - '<error>' . str_pad(str_repeat(' ', $depth) . $line, 140, ' ') . '</error>' |
|
| 362 | + '<error>'.str_pad(str_repeat(' ', $depth).$line, 140, ' ').'</error>' |
|
| 363 | 363 | ); |
| 364 | 364 | } |
| 365 | 365 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Find file |
| 431 | - $fileName = dirname($originFile) . DIRECTORY_SEPARATOR . $documentData['file']; |
|
| 431 | + $fileName = dirname($originFile).DIRECTORY_SEPARATOR.$documentData['file']; |
|
| 432 | 432 | $fileName = str_replace('//', '/', $fileName); |
| 433 | 433 | if (!file_exists($fileName)) { |
| 434 | 434 | return false; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $clientMock = $this->getMockBuilder('\MongoClient')->disableOriginalConstructor()->getMock(); |
| 53 | 53 | |
| 54 | 54 | $collectionMock = $this->getMockBuilder('\MongoCollection')->disableOriginalConstructor()->getMock(); |
| 55 | - $collectionMock->method('save')->will($this->returnCallback(array($this,'saveCollectionCallback'))); |
|
| 55 | + $collectionMock->method('save')->will($this->returnCallback(array($this, 'saveCollectionCallback'))); |
|
| 56 | 56 | |
| 57 | 57 | $dbMock = $this->getMockBuilder('\MongoDB')->disableOriginalConstructor()->getMock(); |
| 58 | 58 | $dbMock->method('selectCollection')->willReturn($collectionMock); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // fail in output? |
| 129 | 129 | $this->assertStringContainsString( |
| 130 | - 'Error in <' . $this->sourceDir . '/Dudess/Invalid.json>: Invalid JSON to unserialize.', |
|
| 130 | + 'Error in <'.$this->sourceDir.'/Dudess/Invalid.json>: Invalid JSON to unserialize.', |
|
| 131 | 131 | $this->cmdTester->getDisplay() |
| 132 | 132 | ); |
| 133 | 133 | $this->assertEquals(1, $this->cmdTester->getStatusCode()); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $responseMock |
| 47 | 47 | ->method('getHeader') |
| 48 | 48 | ->with('Link') |
| 49 | - ->willReturn(['<' . $host . $path . '>; rel="self"']); |
|
| 49 | + ->willReturn(['<'.$host.$path.'>; rel="self"']); |
|
| 50 | 50 | |
| 51 | 51 | $clientMock |
| 52 | 52 | ->method('request') |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | $cmdTester = $this->getTester($sut, $file); |
| 65 | 65 | $display = $cmdTester->getDisplay(); |
| 66 | 66 | |
| 67 | - $this->assertStringContainsString('Loading data from ' . $file, $display); |
|
| 68 | - $this->assertStringContainsString('Wrote <' . $host . $path . '>; rel="self"', $display); |
|
| 67 | + $this->assertStringContainsString('Loading data from '.$file, $display); |
|
| 68 | + $this->assertStringContainsString('Wrote <'.$host.$path.'>; rel="self"', $display); |
|
| 69 | 69 | $this->assertEquals(0, $cmdTester->getStatusCode()); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | return [ |
| 78 | 78 | 'basic valid file' => [ |
| 79 | 79 | 'http://localhost', |
| 80 | - __DIR__ . '/fixtures/set-01/test-2.json', |
|
| 80 | + __DIR__.'/fixtures/set-01/test-2.json', |
|
| 81 | 81 | '/core/app/test', |
| 82 | 82 | ], |
| 83 | 83 | 'basic valid image file' => [ |
| 84 | 84 | 'http://localhost', |
| 85 | - __DIR__ . '/fixtures/file', |
|
| 85 | + __DIR__.'/fixtures/file', |
|
| 86 | 86 | '/core/app/test', |
| 87 | 87 | ], |
| 88 | 88 | ]; |
@@ -109,12 +109,12 @@ discard block |
||
| 109 | 109 | $responseMock |
| 110 | 110 | ->method('getHeader') |
| 111 | 111 | ->with('Link') |
| 112 | - ->willReturn(['<' . $host . $file . '>; rel="self"']); |
|
| 112 | + ->willReturn(['<'.$host.$file.'>; rel="self"']); |
|
| 113 | 113 | |
| 114 | 114 | $requestMock = $this->createMock('Psr\Http\Message\RequestInterface'); |
| 115 | 115 | $requestMock |
| 116 | 116 | ->method('getUri') |
| 117 | - ->willReturn($host . '/core/app/test'); |
|
| 117 | + ->willReturn($host.'/core/app/test'); |
|
| 118 | 118 | |
| 119 | 119 | $exceptionMock = $this->getMockBuilder('GuzzleHttp\Exception\RequestException') |
| 120 | 120 | ->setConstructorArgs(['Client error: 400', $requestMock, $responseMock]) |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $cmdTester = $this->getTester($sut, $file); |
| 145 | 145 | $display = $cmdTester->getDisplay(); |
| 146 | 146 | |
| 147 | - $this->assertStringContainsString('Loading data from ' . $file, $display); |
|
| 147 | + $this->assertStringContainsString('Loading data from '.$file, $display); |
|
| 148 | 148 | foreach ($errors as $error) { |
| 149 | 149 | $this->assertStringContainsString( |
| 150 | 150 | $error, |
@@ -162,18 +162,18 @@ discard block |
||
| 162 | 162 | return [ |
| 163 | 163 | 'invalid file (server side)' => [ |
| 164 | 164 | 'http://localhost', |
| 165 | - __DIR__ . '/fixtures/set-01/test.json', |
|
| 165 | + __DIR__.'/fixtures/set-01/test.json', |
|
| 166 | 166 | [ |
| 167 | - 'Failed to write <http://localhost/core/app/test> from \'' . |
|
| 168 | - __DIR__ . '/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
| 167 | + 'Failed to write <http://localhost/core/app/test> from \''. |
|
| 168 | + __DIR__.'/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
| 169 | 169 | '"message": "invalid"', |
| 170 | 170 | ], |
| 171 | 171 | ], |
| 172 | 172 | 'missing target in file (user error)' => [ |
| 173 | 173 | 'http://localhost', |
| 174 | - __DIR__ . '/fixtures/set-01/test-3.json', |
|
| 174 | + __DIR__.'/fixtures/set-01/test-3.json', |
|
| 175 | 175 | [ |
| 176 | - 'Missing target in \'' . __DIR__ . '/fixtures/set-01/test-3.json\'', |
|
| 176 | + 'Missing target in \''.__DIR__.'/fixtures/set-01/test-3.json\'', |
|
| 177 | 177 | ], |
| 178 | 178 | ] |
| 179 | 179 | ]; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | $cmdTester = $this->getTester( |
| 222 | 222 | $sut, |
| 223 | - __DIR__ . '/fixtures/set-01/test-4.json', |
|
| 223 | + __DIR__.'/fixtures/set-01/test-4.json', |
|
| 224 | 224 | [ |
| 225 | 225 | 'host' => 'http://example.com', |
| 226 | 226 | '--rewrite-host' => 'http://localhost' |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | * @param SplFileInfo $file |
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | - $filter = function (SplFileInfo $file) { |
|
| 87 | - if (!in_array($file->getExtension(), ['yml','json']) || $file->isDir()) { |
|
| 86 | + $filter = function(SplFileInfo $file) { |
|
| 87 | + if (!in_array($file->getExtension(), ['yml', 'json']) || $file->isDir()) { |
|
| 88 | 88 | return false; |
| 89 | 89 | } |
| 90 | 90 | return true; |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $fileList = array_filter( |
| 111 | 111 | $fileList, |
| 112 | - function ($val) { |
|
| 112 | + function($val) { |
|
| 113 | 113 | if (!empty($val)) { |
| 114 | 114 | return true; |
| 115 | 115 | } |