@@ -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 | * |
@@ -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 | { |
@@ -10,7 +10,6 @@ |
||
10 | 10 | namespace Graviton\ImportExport\Command; |
11 | 11 | |
12 | 12 | use Graviton\ImportExport\Exception\MissingTargetException; |
13 | -use Graviton\ImportExport\Exception\JsonParseException; |
|
14 | 13 | use Graviton\ImportExport\Exception\ParseException; |
15 | 14 | use Graviton\ImportExport\Exception\UnknownFileTypeException; |
16 | 15 | use Graviton\ImportExport\Service\HttpClient; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | $this->logger->info("Loading data from ${file}"); |
245 | 245 | |
246 | 246 | if (!array_key_exists('target', $doc->getData())) { |
247 | - throw new MissingTargetException('Missing target in \'' . $file . '\''); |
|
247 | + throw new MissingTargetException('Missing target in \''.$file.'\''); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | $targetUrl = sprintf('%s%s', $host, $doc->getData()['target']); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | // Authentication or custom headers. |
294 | 294 | if ($this->headerBasicAuth) { |
295 | - $data['headers']['Authorization'] = 'Basic '. base64_encode($this->headerBasicAuth); |
|
295 | + $data['headers']['Authorization'] = 'Basic '.base64_encode($this->headerBasicAuth); |
|
296 | 296 | } |
297 | 297 | if ($this->customHeaders) { |
298 | 298 | foreach ($this->customHeaders as $headers) { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $data |
343 | 343 | ); |
344 | 344 | |
345 | - $this->logger->info('Wrote ' . $response->getHeader('Link')[0]); |
|
345 | + $this->logger->info('Wrote '.$response->getHeader('Link')[0]); |
|
346 | 346 | } catch (\Exception $e) { |
347 | 347 | $this->errors[$file] = $e->getMessage(); |
348 | 348 | $this->logger->error( |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | $this->cloner->cloneVar( |
360 | 360 | $this->parser->parse($e->getResponse()->getBody(), Yaml::PARSE_OBJECT_FOR_MAP) |
361 | 361 | ), |
362 | - function ($line, $depth) use ($output) { |
|
362 | + function($line, $depth) use ($output) { |
|
363 | 363 | if ($depth > 0) { |
364 | 364 | $output->writeln( |
365 | - '<error>' . str_pad(str_repeat(' ', $depth) . $line, 140, ' ') . '</error>' |
|
365 | + '<error>'.str_pad(str_repeat(' ', $depth).$line, 140, ' ').'</error>' |
|
366 | 366 | ); |
367 | 367 | } |
368 | 368 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | // Find file |
434 | - $fileName = dirname($originFile) . DIRECTORY_SEPARATOR . $documentData['file']; |
|
434 | + $fileName = dirname($originFile).DIRECTORY_SEPARATOR.$documentData['file']; |
|
435 | 435 | $fileName = str_replace('//', '/', $fileName); |
436 | 436 | if (!file_exists($fileName)) { |
437 | 437 | 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; |
@@ -59,7 +59,7 @@ |
||
59 | 59 | * |
60 | 60 | * @param InputInterface $input User input on console |
61 | 61 | * |
62 | - * @return Finder|SplFileInfo[] finder |
|
62 | + * @return Finder finder |
|
63 | 63 | */ |
64 | 64 | protected function getFinder($input) |
65 | 65 | { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | try { |
50 | 50 | $exitCode = $this->doImport($this->getFinder($input), $input, $output); |
51 | 51 | } catch (MissingTargetException $e) { |
52 | - $output->writeln('<error>' . $e->getMessage() . '</error>'); |
|
52 | + $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
53 | 53 | } |
54 | 54 | return $exitCode; |
55 | 55 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param SplFileInfo $file |
77 | 77 | * @return bool |
78 | 78 | */ |
79 | - $filter = function (SplFileInfo $file) { |
|
80 | - if (!in_array($file->getExtension(), ['yml','json']) || $file->isDir()) { |
|
79 | + $filter = function(SplFileInfo $file) { |
|
80 | + if (!in_array($file->getExtension(), ['yml', 'json']) || $file->isDir()) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | return true; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $fileList = array_filter( |
104 | 104 | $fileList, |
105 | - function ($val) { |
|
105 | + function($val) { |
|
106 | 106 | if (!empty($val)) { |
107 | 107 | return true; |
108 | 108 | } |
@@ -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()); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | public static function getFullStringFromLog(TestHandler $handler) |
40 | 40 | { |
41 | 41 | $entries = array_map( |
42 | - function ($val) { |
|
42 | + function($val) { |
|
43 | 43 | return $val['formatted']; |
44 | 44 | }, |
45 | 45 | $handler->getRecords() |
@@ -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') |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | $cmdTester = $this->getTester($sut, $file); |
68 | 68 | $display = TestUtils::getFullStringFromLog($logger->getHandlers()[0]); |
69 | 69 | |
70 | - $this->assertContains('Loading data from ' . $file, $display); |
|
71 | - $this->assertContains('Wrote <' . $host . $path . '>; rel="self"', $display); |
|
70 | + $this->assertContains('Loading data from '.$file, $display); |
|
71 | + $this->assertContains('Wrote <'.$host.$path.'>; rel="self"', $display); |
|
72 | 72 | $this->assertEquals(0, $cmdTester->getStatusCode()); |
73 | 73 | } |
74 | 74 | |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | return [ |
81 | 81 | 'basic valid file' => [ |
82 | 82 | 'http://localhost', |
83 | - __DIR__ . '/fixtures/set-01/test-2.json', |
|
83 | + __DIR__.'/fixtures/set-01/test-2.json', |
|
84 | 84 | '/core/app/test', |
85 | 85 | ], |
86 | 86 | 'basic valid image file' => [ |
87 | 87 | 'http://localhost', |
88 | - __DIR__ . '/fixtures/file', |
|
88 | + __DIR__.'/fixtures/file', |
|
89 | 89 | '/core/app/test', |
90 | 90 | ], |
91 | 91 | ]; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | $responseMock |
113 | 113 | ->method('getHeader') |
114 | 114 | ->with('Link') |
115 | - ->willReturn(['<' . $host . $file . '>; rel="self"']); |
|
115 | + ->willReturn(['<'.$host.$file.'>; rel="self"']); |
|
116 | 116 | |
117 | 117 | $requestMock = $this->createMock('Psr\Http\Message\RequestInterface'); |
118 | 118 | $requestMock |
119 | 119 | ->method('getUri') |
120 | - ->willReturn($host . '/core/app/test'); |
|
120 | + ->willReturn($host.'/core/app/test'); |
|
121 | 121 | |
122 | 122 | $exceptionMock = $this->getMockBuilder('GuzzleHttp\Exception\RequestException') |
123 | 123 | ->setConstructorArgs(['Client error: 400', $requestMock, $responseMock]) |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $cmdTester = $this->getTester($sut, $file); |
151 | 151 | $display = TestUtils::getFullStringFromLog($logger->getHandlers()[0]); |
152 | 152 | |
153 | - $this->assertContains('Loading data from ' . $file, $display); |
|
153 | + $this->assertContains('Loading data from '.$file, $display); |
|
154 | 154 | foreach ($errors as $error) { |
155 | 155 | $this->assertContains( |
156 | 156 | $error, |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | return [ |
169 | 169 | 'invalid file (server side)' => [ |
170 | 170 | 'http://localhost', |
171 | - __DIR__ . '/fixtures/set-01/test.json', |
|
171 | + __DIR__.'/fixtures/set-01/test.json', |
|
172 | 172 | [ |
173 | - 'Failed to write <http://localhost/core/app/test> from \'' . |
|
174 | - __DIR__ . '/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
173 | + 'Failed to write <http://localhost/core/app/test> from \''. |
|
174 | + __DIR__.'/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
175 | 175 | '"message": "invalid"', |
176 | 176 | ], |
177 | 177 | ], |
178 | 178 | 'missing target in file (user error)' => [ |
179 | 179 | 'http://localhost', |
180 | - __DIR__ . '/fixtures/set-01/test-3.json', |
|
180 | + __DIR__.'/fixtures/set-01/test-3.json', |
|
181 | 181 | [ |
182 | - 'Missing target in \'' . __DIR__ . '/fixtures/set-01/test-3.json\'', |
|
182 | + 'Missing target in \''.__DIR__.'/fixtures/set-01/test-3.json\'', |
|
183 | 183 | ], |
184 | 184 | ] |
185 | 185 | ]; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | $cmdTester = $this->getTester( |
231 | 231 | $sut, |
232 | - __DIR__ . '/fixtures/set-01/test-4.json', |
|
232 | + __DIR__.'/fixtures/set-01/test-4.json', |
|
233 | 233 | [ |
234 | 234 | 'host' => 'http://example.com', |
235 | 235 | '--rewrite-host' => 'http://localhost' |