@@ -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 | * |
@@ -211,7 +211,7 @@ |
||
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, |
@@ -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']); |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | ) { |
226 | 226 | $content = str_replace($rewriteHost, $rewriteTo, $doc->getContent()); |
227 | 227 | |
228 | - $successFunc = function (ResponseInterface $response) use ($output) { |
|
228 | + $successFunc = function(ResponseInterface $response) use ($output) { |
|
229 | 229 | $output->writeln( |
230 | - '<comment>Wrote ' . $response->getHeader('Link')[0] . '</comment>' |
|
230 | + '<comment>Wrote '.$response->getHeader('Link')[0].'</comment>' |
|
231 | 231 | ); |
232 | 232 | }; |
233 | 233 | |
234 | - $errFunc = function (RequestException $e) use ($output, $file) { |
|
234 | + $errFunc = function(RequestException $e) use ($output, $file) { |
|
235 | 235 | $output->writeln( |
236 | - '<error>' . str_pad( |
|
236 | + '<error>'.str_pad( |
|
237 | 237 | sprintf( |
238 | 238 | 'Failed to write <%s> from \'%s\' with message \'%s\'', |
239 | 239 | $e->getRequest()->getUri(), |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | ), |
243 | 243 | 140, |
244 | 244 | ' ' |
245 | - ) . '</error>' |
|
245 | + ).'</error>' |
|
246 | 246 | ); |
247 | 247 | if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { |
248 | 248 | $this->dumper->dump( |
249 | 249 | $this->cloner->cloneVar( |
250 | 250 | $this->parser->parse($e->getResponse()->getBody(), false, false, true) |
251 | 251 | ), |
252 | - function ($line, $depth) use ($output) { |
|
252 | + function($line, $depth) use ($output) { |
|
253 | 253 | if ($depth > 0) { |
254 | 254 | $output->writeln( |
255 | - '<error>' . str_pad(str_repeat(' ', $depth) . $line, 140, ' ') . '</error>' |
|
255 | + '<error>'.str_pad(str_repeat(' ', $depth).$line, 140, ' ').'</error>' |
|
256 | 256 | ); |
257 | 257 | } |
258 | 258 | } |
@@ -46,13 +46,13 @@ 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 | $promiseMock |
52 | 52 | ->method('then') |
53 | 53 | ->will( |
54 | 54 | $this->returnCallback( |
55 | - function ($ok) use ($responseMock) { |
|
55 | + function($ok) use ($responseMock) { |
|
56 | 56 | $ok($responseMock); |
57 | 57 | } |
58 | 58 | ) |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | |
70 | 70 | $cmdTester = $this->getTester($sut, $file); |
71 | 71 | |
72 | - $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay()); |
|
73 | - $this->assertContains('Wrote <' . $host . $path . '>; rel="self"', $cmdTester->getDisplay()); |
|
72 | + $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay()); |
|
73 | + $this->assertContains('Wrote <'.$host.$path.'>; rel="self"', $cmdTester->getDisplay()); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | return [ |
82 | 82 | 'basic valid file' => [ |
83 | 83 | 'http://localhost', |
84 | - __DIR__ . '/fixtures/set-01/test-2.json', |
|
84 | + __DIR__.'/fixtures/set-01/test-2.json', |
|
85 | 85 | '/core/app/test', |
86 | 86 | ], |
87 | 87 | ]; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $requestMock = $this->getMock('Psr\Http\Message\RequestInterface'); |
116 | 116 | $requestMock |
117 | 117 | ->method('getUri') |
118 | - ->willReturn($host . '/core/app/test'); |
|
118 | + ->willReturn($host.'/core/app/test'); |
|
119 | 119 | |
120 | 120 | $exceptionMock = $this->getMockBuilder('GuzzleHttp\Exception\RequestException') |
121 | 121 | ->setConstructorArgs(['Client error: 400', $requestMock, $responseMock]) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ->method('then') |
134 | 134 | ->will( |
135 | 135 | $this->returnCallback( |
136 | - function ($ok, $nok) use ($exceptionMock) { |
|
136 | + function($ok, $nok) use ($exceptionMock) { |
|
137 | 137 | return $nok($exceptionMock); |
138 | 138 | } |
139 | 139 | ) |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $cmdTester = $this->getTester($sut, $file); |
152 | 152 | |
153 | - $this->assertContains('Loading data from ' . $file, $cmdTester->getDisplay()); |
|
153 | + $this->assertContains('Loading data from '.$file, $cmdTester->getDisplay()); |
|
154 | 154 | foreach ($errors as $error) { |
155 | 155 | $this->assertContains( |
156 | 156 | $error, |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | return [ |
168 | 168 | 'invalid file (server side)' => [ |
169 | 169 | 'http://localhost', |
170 | - __DIR__ . '/fixtures/set-01/test.json', |
|
170 | + __DIR__.'/fixtures/set-01/test.json', |
|
171 | 171 | [ |
172 | - 'Failed to write <http://localhost/core/app/test> from \'' . |
|
173 | - __DIR__ . '/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
172 | + 'Failed to write <http://localhost/core/app/test> from \''. |
|
173 | + __DIR__.'/fixtures/set-01/test.json\' with message \'Client error: 400\'', |
|
174 | 174 | '"message": "invalid"', |
175 | 175 | ], |
176 | 176 | ], |
177 | 177 | 'missing target in file (user error)' => [ |
178 | 178 | 'http://localhost', |
179 | - __DIR__ . '/fixtures/set-01/test-3.json', |
|
179 | + __DIR__.'/fixtures/set-01/test-3.json', |
|
180 | 180 | [ |
181 | - 'Missing target in \'' . __DIR__ . '/fixtures/set-01/test-3.json\'', |
|
181 | + 'Missing target in \''.__DIR__.'/fixtures/set-01/test-3.json\'', |
|
182 | 182 | ], |
183 | 183 | ] |
184 | 184 | ]; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ->method('then') |
216 | 216 | ->will( |
217 | 217 | $this->returnCallback( |
218 | - function ($ok) use ($responseMock) { |
|
218 | + function($ok) use ($responseMock) { |
|
219 | 219 | $ok($responseMock); |
220 | 220 | } |
221 | 221 | ) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | $cmdTester = $this->getTester( |
234 | 234 | $sut, |
235 | - __DIR__ . '/fixtures/set-01/test-4.json', |
|
235 | + __DIR__.'/fixtures/set-01/test-4.json', |
|
236 | 236 | [ |
237 | 237 | 'host' => 'http://example.com', |
238 | 238 | '--rewrite-host' => 'http://localhost' |
@@ -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 |