@@ -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 | { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $output->writeln("<info>Loading data from ${file}</info>"); |
232 | 232 | |
233 | 233 | if (!array_key_exists('target', $doc->getData())) { |
234 | - throw new MissingTargetException('Missing target in \'' . $file . '\''); |
|
234 | + throw new MissingTargetException('Missing target in \''.$file.'\''); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | $targetUrl = sprintf('%s%s', $host, $doc->getData()['target']); |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | $content = str_replace($rewriteHost, $rewriteTo, $doc->getContent()); |
278 | 278 | $uploadFile = $this->validateUploadFile($doc, $file); |
279 | 279 | |
280 | - $successFunc = function (ResponseInterface $response) use ($output) { |
|
280 | + $successFunc = function(ResponseInterface $response) use ($output) { |
|
281 | 281 | $output->writeln( |
282 | - '<comment>Wrote ' . $response->getHeader('Link')[0] . '</comment>' |
|
282 | + '<comment>Wrote '.$response->getHeader('Link')[0].'</comment>' |
|
283 | 283 | ); |
284 | 284 | }; |
285 | 285 | |
286 | - $errFunc = function (RequestException $e) use ($output, $file) { |
|
286 | + $errFunc = function(RequestException $e) use ($output, $file) { |
|
287 | 287 | $this->errors[$file] = $e->getMessage(); |
288 | 288 | $output->writeln( |
289 | - '<error>' . str_pad( |
|
289 | + '<error>'.str_pad( |
|
290 | 290 | sprintf( |
291 | 291 | 'Failed to write <%s> from \'%s\' with message \'%s\'', |
292 | 292 | $e->getRequest()->getUri(), |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | ), |
296 | 296 | 140, |
297 | 297 | ' ' |
298 | - ) . '</error>' |
|
298 | + ).'</error>' |
|
299 | 299 | ); |
300 | 300 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
301 | 301 | $this->dumper->dump( |
302 | 302 | $this->cloner->cloneVar( |
303 | 303 | $this->parser->parse($e->getResponse()->getBody(), false, false, true) |
304 | 304 | ), |
305 | - function ($line, $depth) use ($output) { |
|
305 | + function($line, $depth) use ($output) { |
|
306 | 306 | if ($depth > 0) { |
307 | 307 | $output->writeln( |
308 | - '<error>' . str_pad(str_repeat(' ', $depth) . $line, 140, ' ') . '</error>' |
|
308 | + '<error>'.str_pad(str_repeat(' ', $depth).$line, 140, ' ').'</error>' |
|
309 | 309 | ); |
310 | 310 | } |
311 | 311 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | // Authentication or custom headers. |
323 | 323 | if ($this->headerBasicAuth) { |
324 | - $data['headers']['Authorization'] = 'Basic '. base64_encode($this->headerBasicAuth); |
|
324 | + $data['headers']['Authorization'] = 'Basic '.base64_encode($this->headerBasicAuth); |
|
325 | 325 | } |
326 | 326 | if ($this->customHeaders) { |
327 | 327 | foreach ($this->customHeaders as $headers) { |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | // TODO This part, $uploadFile, promise should be removed once Graviton/File service is resolved in new Story. |
344 | 344 | $fileRepeatFunc = false; |
345 | 345 | if ($uploadFile) { |
346 | - $fileRepeatFunc = function () use ($targetUrl, $successFunc, $errFunc, $output, $file, $data) { |
|
346 | + $fileRepeatFunc = function() use ($targetUrl, $successFunc, $errFunc, $output, $file, $data) { |
|
347 | 347 | unset($this->errors[$file]); |
348 | 348 | $output->writeln('<info>File deleting: '.$targetUrl.'</info>'); |
349 | 349 | $deleteRequest = $this->client->requestAsync('DELETE', $targetUrl); |
350 | - $insert = function () use ($targetUrl, $successFunc, $errFunc, $output, $data) { |
|
350 | + $insert = function() use ($targetUrl, $successFunc, $errFunc, $output, $data) { |
|
351 | 351 | $output->writeln('<info>File inserting: '.$targetUrl.'</info>'); |
352 | 352 | $promiseInsert = $this->client->requestAsync('PUT', $targetUrl, $data); |
353 | 353 | $promiseInsert->then($successFunc, $errFunc); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | } |
418 | 418 | |
419 | 419 | // Find file |
420 | - $fileName = dirname($originFile) . DIRECTORY_SEPARATOR . $documentData['file']; |
|
420 | + $fileName = dirname($originFile).DIRECTORY_SEPARATOR.$documentData['file']; |
|
421 | 421 | $fileName = str_replace('//', '/', $fileName); |
422 | 422 | if (!file_exists($fileName)) { |
423 | 423 | return false; |
@@ -6,12 +6,10 @@ |
||
6 | 6 | |
7 | 7 | namespace Graviton\ImportExport\Command; |
8 | 8 | |
9 | -use Graviton\ImportExport\Exception\MissingTargetException; |
|
10 | 9 | use Symfony\Component\Console\Command\Command; |
11 | 10 | use Symfony\Component\Console\Helper\ProgressBar; |
12 | 11 | use Symfony\Component\Console\Input\InputArgument; |
13 | 12 | use Symfony\Component\Console\Input\InputInterface; |
14 | -use Symfony\Component\Console\Input\InputOption; |
|
15 | 13 | use Symfony\Component\Console\Output\OutputInterface; |
16 | 14 | use Symfony\Component\Finder\Finder; |
17 | 15 | use Symfony\Component\Finder\SplFileInfo; |
@@ -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 | } |