Completed
Push — master ( 475749...c0b163 )
by Aimeos
02:12
created
controller/jobs/src/Controller/Jobs/Subscription/Process/Base.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@
 block discarded – undo
27 27
 	 * @param array $pnames List of processor names
28 28
 	 * @return \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Iface Processor object
29 29
 	 */
30
-	protected function getProcessors( array $pnames )
30
+	protected function getProcessors(array $pnames)
31 31
 	{
32 32
 		$list = [];
33 33
 		$context = $this->getContext();
34 34
 		$config = $context->getConfig();
35 35
 
36
-		foreach( $pnames as $pname )
36
+		foreach ($pnames as $pname)
37 37
 		{
38
-			if( ctype_alnum( $pname ) === false )
38
+			if (ctype_alnum($pname) === false)
39 39
 			{
40 40
 				$classname = is_string($pname) ? '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . $pname : '<not a string>';
41
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
41
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
42 42
 			}
43 43
 
44
-			$name = $config->get( 'controller/common/subscription/process/processor/' . $pname . '/name', 'Standard' );
44
+			$name = $config->get('controller/common/subscription/process/processor/' . $pname . '/name', 'Standard');
45 45
 
46
-			if( ctype_alnum( $name ) === false )
46
+			if (ctype_alnum($name) === false)
47 47
 			{
48 48
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . $pname . '\\' . $name : '<not a string>';
49
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
49
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
50 50
 			}
51 51
 
52
-			$classname = '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . ucfirst( $pname ) . '\\' . $name;
52
+			$classname = '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\' . ucfirst($pname) . '\\' . $name;
53 53
 
54
-			if( class_exists( $classname ) === false ) {
55
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
54
+			if (class_exists($classname) === false) {
55
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
56 56
 			}
57 57
 
58
-			$object = new $classname( $context );
58
+			$object = new $classname($context);
59 59
 
60
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\Iface', $object );
60
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Subscription\\Process\\Processor\\Iface', $object);
61 61
 
62 62
 			$list[$pname] = $object;
63 63
 		}
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Product/Export/Standard.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Product export' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Product export');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports all available products' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports all available products');
43 43
 	}
44 44
 
45 45
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	public function run()
52 52
 	{
53 53
 		$container = $this->createContainer();
54
-		$this->export( $container, false );
54
+		$this->export($container, false);
55 55
 		$container->close();
56 56
 	}
57 57
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param \Aimeos\MW\Container\Content\Iface $content File content object
63 63
 	 * @param \Aimeos\MShop\Product\Item\Iface[] $items List of product items
64 64
 	 */
65
-	protected function addItems( \Aimeos\MW\Container\Content\Iface $content, array $items )
65
+	protected function addItems(\Aimeos\MW\Container\Content\Iface $content, array $items)
66 66
 	{
67 67
 		/** controller/jobs/product/export/standard/template-items
68 68
 		 * Relative path to the XML items template of the product site map job controller.
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$view->exportItems = $items;
96 96
 
97
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
97
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
98 98
 	}
99 99
 
100 100
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		 * @see controller/jobs/product/export/max-items
124 124
 		 * @see controller/jobs/product/export/max-query
125 125
 		 */
126
-		$location = $config->get( 'controller/jobs/product/export/location' );
126
+		$location = $config->get('controller/jobs/product/export/location');
127 127
 
128 128
 		/** controller/jobs/product/export/standard/container/type
129 129
 		 * List of file container options for the export files
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		 * @see controller/jobs/product/export/max-items
141 141
 		 * @see controller/jobs/product/export/max-query
142 142
 		 */
143
-		$container = $config->get( 'controller/jobs/product/export/standard/container/type', 'Directory' );
143
+		$container = $config->get('controller/jobs/product/export/standard/container/type', 'Directory');
144 144
 
145 145
 		/** controller/jobs/product/export/standard/container/content
146 146
 		 * List of file container options for the export files
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		 * @see controller/jobs/product/export/max-items
158 158
 		 * @see controller/jobs/product/export/max-query
159 159
 		 */
160
-		$content = $config->get( 'controller/jobs/product/export/standard/container/content', 'Binary' );
160
+		$content = $config->get('controller/jobs/product/export/standard/container/content', 'Binary');
161 161
 
162 162
 		/** controller/jobs/product/export/standard/container/options
163 163
 		 * List of file container options for the export files
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 		 * @see controller/jobs/product/export/max-items
175 175
 		 * @see controller/jobs/product/export/max-query
176 176
 		 */
177
-		$options = $config->get( 'controller/jobs/product/export/standard/container/options', [] );
177
+		$options = $config->get('controller/jobs/product/export/standard/container/options', []);
178 178
 
179
-		if( $location === null )
179
+		if ($location === null)
180 180
 		{
181
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location' );
182
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
181
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/product/export/location');
182
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
183 183
 		}
184 184
 
185
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
185
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
186 186
 	}
187 187
 
188 188
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param integer $filenum New file number
194 194
 	 * @return \Aimeos\MW\Container\Content\Iface New content object
195 195
 	 */
196
-	protected function createContent( \Aimeos\MW\Container\Iface $container, $filenum )
196
+	protected function createContent(\Aimeos\MW\Container\Iface $container, $filenum)
197 197
 	{
198 198
 		/** controller/jobs/product/export/standard/template-header
199 199
 		 * Relative path to the XML site map header template of the product site map job controller.
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 		$context = $this->getContext();
224 224
 		$view = $context->getView();
225 225
 
226
-		$content = $container->create( $this->getFilename( $filenum ) );
227
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
228
-		$container->add( $content );
226
+		$content = $container->create($this->getFilename($filenum));
227
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
228
+		$container->add($content);
229 229
 
230 230
 		return $content;
231 231
 	}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @param \Aimeos\MW\Container\Content\Iface $content
238 238
 	 */
239
-	protected function closeContent( \Aimeos\MW\Container\Content\Iface $content )
239
+	protected function closeContent(\Aimeos\MW\Container\Content\Iface $content)
240 240
 	{
241 241
 		/** controller/jobs/product/export/standard/template-footer
242 242
 		 * Relative path to the XML site map footer template of the product site map job controller.
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		$context = $this->getContext();
267 267
 		$view = $context->getView();
268 268
 
269
-		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
269
+		$content->add($view->render($context->getConfig()->get($tplconf, $default)));
270 270
 	}
271 271
 
272 272
 
@@ -277,45 +277,45 @@  discard block
 block discarded – undo
277 277
 	 * @param boolean $default True to filter exported products by default criteria
278 278
 	 * @return array List of content (file) names
279 279
 	 */
280
-	protected function export( \Aimeos\MW\Container\Iface $container, $default = true )
280
+	protected function export(\Aimeos\MW\Container\Iface $container, $default = true)
281 281
 	{
282
-		$domains = array( 'attribute', 'media', 'price', 'product', 'text' );
282
+		$domains = array('attribute', 'media', 'price', 'product', 'text');
283 283
 
284
-		$domains = $this->getConfig( 'domains', $domains );
285
-		$maxItems = $this->getConfig( 'max-items', 10000 );
286
-		$maxQuery = $this->getConfig( 'max-query', 1000 );
284
+		$domains = $this->getConfig('domains', $domains);
285
+		$maxItems = $this->getConfig('max-items', 10000);
286
+		$maxQuery = $this->getConfig('max-query', 1000);
287 287
 
288 288
 		$start = 0; $filenum = 1;
289 289
 		$names = [];
290 290
 
291
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
291
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
292 292
 
293
-		$search = $productManager->createSearch( $default );
294
-		$search->setSortations( array( $search->sort( '+', 'product.id' ) ) );
295
-		$search->setSlice( 0, $maxQuery );
293
+		$search = $productManager->createSearch($default);
294
+		$search->setSortations(array($search->sort('+', 'product.id')));
295
+		$search->setSlice(0, $maxQuery);
296 296
 
297
-		$content = $this->createContent( $container, $filenum );
297
+		$content = $this->createContent($container, $filenum);
298 298
 		$names[] = $content->getResource();
299 299
 
300 300
 		do
301 301
 		{
302
-			$items = $productManager->searchItems( $search, $domains );
303
-			$this->addItems( $content, $items );
302
+			$items = $productManager->searchItems($search, $domains);
303
+			$this->addItems($content, $items);
304 304
 
305
-			$count = count( $items );
305
+			$count = count($items);
306 306
 			$start += $count;
307
-			$search->setSlice( $start, $maxQuery );
307
+			$search->setSlice($start, $maxQuery);
308 308
 
309
-			if( $start + $maxQuery > $maxItems * $filenum )
309
+			if ($start + $maxQuery > $maxItems * $filenum)
310 310
 			{
311
-				$this->closeContent( $content );
312
-				$content = $this->createContent( $container, ++$filenum );
311
+				$this->closeContent($content);
312
+				$content = $this->createContent($container, ++$filenum);
313 313
 				$names[] = $content->getResource();
314 314
 			}
315 315
 		}
316
-		while( $count >= $search->getSliceSize() );
316
+		while ($count >= $search->getSliceSize());
317 317
 
318
-		$this->closeContent( $content );
318
+		$this->closeContent($content);
319 319
 
320 320
 		return $names;
321 321
 	}
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 	 * @param mixed $default Default value if name is unknown
329 329
 	 * @return mixed Configuration value
330 330
 	 */
331
-	protected function getConfig( $name, $default = null )
331
+	protected function getConfig($name, $default = null)
332 332
 	{
333 333
 		$config = $this->getContext()->getConfig();
334 334
 
335
-		switch( $name )
335
+		switch ($name)
336 336
 		{
337 337
 			case 'domain':
338 338
 				/** controller/jobs/product/export/domains
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 				 * @see controller/jobs/product/export/max-items
356 356
 				 * @see controller/jobs/product/export/max-query
357 357
 				 */
358
-				return $config->get( 'controller/jobs/product/export/domains', $default );
358
+				return $config->get('controller/jobs/product/export/domains', $default);
359 359
 
360 360
 			case 'max-items':
361 361
 				/** controller/jobs/product/export/max-items
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 				 * @see controller/jobs/product/export/max-query
379 379
 				 * @see controller/jobs/product/export/domains
380 380
 				 */
381
-				return $config->get( 'controller/jobs/product/export/max-items', $default );
381
+				return $config->get('controller/jobs/product/export/max-items', $default);
382 382
 
383 383
 			case 'max-query':
384 384
 				/** controller/jobs/product/export/max-query
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 				 * @see controller/jobs/product/export/max-items
402 402
 				 * @see controller/jobs/product/export/domains
403 403
 				 */
404
-				return $config->get( 'controller/jobs/product/export/max-query', $default );
404
+				return $config->get('controller/jobs/product/export/max-query', $default);
405 405
 
406 406
 			case 'filename':
407 407
 				/** controller/jobs/product/export/filename
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 				 * @see controller/jobs/product/export/max-query
423 423
 				 * @see controller/jobs/product/export/domains
424 424
 				 */
425
-				return $config->get( 'controller/jobs/product/export/filename', $default );
425
+				return $config->get('controller/jobs/product/export/filename', $default);
426 426
 		}
427 427
 
428 428
 		return $default;
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	 * @param integer $number Current file number
436 436
 	 * @return string New file name
437 437
 	 */
438
-	protected function getFilename( $number )
438
+	protected function getFilename($number)
439 439
 	{
440
-		return sprintf( $this->getConfig( 'filename', 'aimeos-products-%1$d_%2$s.xml' ), $number, date( 'Y-m-d_H:i:s' ) );
440
+		return sprintf($this->getConfig('filename', 'aimeos-products-%1$d_%2$s.xml'), $number, date('Y-m-d_H:i:s'));
441 441
 	}
442 442
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Order/Export/Csv/Base.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -142,37 +142,37 @@
 block discarded – undo
142 142
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
143 143
 	 * @return \Aimeos\Controller\Common\Order\Export\Csv\Processor\Iface Processor object
144 144
 	 */
145
-	protected function getProcessors( array $mappings )
145
+	protected function getProcessors(array $mappings)
146 146
 	{
147 147
 		$list = [];
148 148
 		$context = $this->getContext();
149 149
 		$config = $context->getConfig();
150 150
 
151
-		foreach( $mappings as $type => $mapping )
151
+		foreach ($mappings as $type => $mapping)
152 152
 		{
153
-			if( ctype_alnum( $type ) === false )
153
+			if (ctype_alnum($type) === false)
154 154
 			{
155 155
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . $type : '<not a string>';
156
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
156
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
157 157
 			}
158 158
 
159
-			$name = $config->get( 'controller/common/order/export/csv/processor/' . $type . '/name', 'Standard' );
159
+			$name = $config->get('controller/common/order/export/csv/processor/' . $type . '/name', 'Standard');
160 160
 
161
-			if( ctype_alnum( $name ) === false )
161
+			if (ctype_alnum($name) === false)
162 162
 			{
163 163
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
164
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
164
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
165 165
 			}
166 166
 
167
-			$classname = '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
167
+			$classname = '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
168 168
 
169
-			if( class_exists( $classname ) === false ) {
170
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
169
+			if (class_exists($classname) === false) {
170
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
171 171
 			}
172 172
 
173
-			$object = new $classname( $context, $mapping );
173
+			$object = new $classname($context, $mapping);
174 174
 
175
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\Iface', $object );
175
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Order\\Export\\Csv\\Processor\\Iface', $object);
176 176
 
177 177
 			$list[$type] = $object;
178 178
 		}
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Product/Export/StandardTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 
19 19
 	protected function setUp()
20 20
 	{
21
-		\Aimeos\MShop\Factory::setCache( true );
21
+		\Aimeos\MShop\Factory::setCache(true);
22 22
 
23 23
 		$this->context = \TestHelperJobs::getContext();
24 24
 		$this->aimeos = \TestHelperJobs::getAimeos();
25 25
 
26
-		$this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard( $this->context, $this->aimeos );
26
+		$this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard($this->context, $this->aimeos);
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		\Aimeos\MShop\Factory::setCache( false );
32
+		\Aimeos\MShop\Factory::setCache(false);
33 33
 		\Aimeos\MShop\Factory::clear();
34 34
 
35 35
 		$this->object = null;
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
 
39 39
 	public function testGetName()
40 40
 	{
41
-		$this->assertEquals( 'Product export', $this->object->getName() );
41
+		$this->assertEquals('Product export', $this->object->getName());
42 42
 	}
43 43
 
44 44
 
45 45
 	public function testGetDescription()
46 46
 	{
47 47
 		$text = 'Exports all available products';
48
-		$this->assertEquals( $text, $this->object->getDescription() );
48
+		$this->assertEquals($text, $this->object->getDescription());
49 49
 	}
50 50
 
51 51
 
52 52
 	public function testRun()
53 53
 	{
54
-		$this->context->getConfig()->set( 'controller/jobs/product/export/filename', 'aimeos-products-%1$d.xml' );
54
+		$this->context->getConfig()->set('controller/jobs/product/export/filename', 'aimeos-products-%1$d.xml');
55 55
 
56 56
 		$this->object->run();
57 57
 
58 58
 		$ds = DIRECTORY_SEPARATOR;
59
-		$this->assertFileExists( 'tmp' . $ds . 'aimeos-products-1.xml' );
60
-		$this->assertFileExists( 'tmp' . $ds . 'aimeos-products-2.xml' );
59
+		$this->assertFileExists('tmp' . $ds . 'aimeos-products-1.xml');
60
+		$this->assertFileExists('tmp' . $ds . 'aimeos-products-2.xml');
61 61
 
62
-		$file1 = file_get_contents( 'tmp' . $ds . 'aimeos-products-1.xml' );
63
-		$file2 = file_get_contents( 'tmp' . $ds . 'aimeos-products-2.xml' );
62
+		$file1 = file_get_contents('tmp' . $ds . 'aimeos-products-1.xml');
63
+		$file2 = file_get_contents('tmp' . $ds . 'aimeos-products-2.xml');
64 64
 
65
-		unlink( 'tmp' . $ds . 'aimeos-products-1.xml' );
66
-		unlink( 'tmp' . $ds . 'aimeos-products-2.xml' );
65
+		unlink('tmp' . $ds . 'aimeos-products-1.xml');
66
+		unlink('tmp' . $ds . 'aimeos-products-2.xml');
67 67
 
68
-		$this->assertContains( 'CNE', $file2 );
69
-		$this->assertContains( 'U:BUNDLE', $file2 );
68
+		$this->assertContains('CNE', $file2);
69
+		$this->assertContains('U:BUNDLE', $file2);
70 70
 	}
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
common/src/Controller/Common/Product/Import/Csv/Processor/Done.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
28 28
 	 * @param \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor Decorated processor
29 29
 	 */
30
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
31
-		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null )
30
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
31
+		\Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface $processor = null)
32 32
 	{
33 33
 	}
34 34
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param array $data List of CSV fields with position as key and data as value
41 41
 	 * @return array List of data which hasn't been imported
42 42
 	 */
43
-	public function process( \Aimeos\MShop\Product\Item\Iface $item, array $data )
43
+	public function process(\Aimeos\MShop\Product\Item\Iface $item, array $data)
44 44
 	{
45 45
 		return $data;
46 46
 	}
Please login to merge, or discard this patch.
controller/common/src/Controller/Common/Coupon/Import/Csv/Base.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
 	 * @param array $codes List of coupon codes
27 27
 	 * @return array Associative list of coupon codes as key and coupon code items as value
28 28
 	 */
29
-	protected function getCouponCodeItems( array $codes )
29
+	protected function getCouponCodeItems(array $codes)
30 30
 	{
31 31
 		$result = [];
32
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' );
32
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code');
33 33
 
34 34
 		$search = $manager->createSearch();
35
-		$search->setConditions( $search->compare( '==', 'coupon.code.code', $codes ) );
36
-		$search->setSlice( 0, count( $codes ) );
35
+		$search->setConditions($search->compare('==', 'coupon.code.code', $codes));
36
+		$search->setSlice(0, count($codes));
37 37
 
38
-		foreach( $manager->searchItems( $search ) as $item ) {
39
-			$result[ $item->getCode() ] = $item;
38
+		foreach ($manager->searchItems($search) as $item) {
39
+			$result[$item->getCode()] = $item;
40 40
 		}
41 41
 
42 42
 		return $result;
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	 * @param integer $codePos Column position which contains the unique coupon code (starting from 0)
52 52
 	 * @return array List of arrays with coupon codes as keys and list of values from the CSV file
53 53
 	 */
54
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
54
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
55 55
 	{
56 56
 		$count = 0;
57 57
 		$data = [];
58 58
 
59
-		while( $content->valid() && $count++ < $maxcnt )
59
+		while ($content->valid() && $count++ < $maxcnt)
60 60
 		{
61 61
 			$row = $content->current();
62
-			$data[ $row[$codePos] ] = $row;
62
+			$data[$row[$codePos]] = $row;
63 63
 			$content->next();
64 64
 		}
65 65
 
@@ -98,21 +98,21 @@  discard block
 block discarded – undo
98 98
 	 * @param array $mapping List of domain item keys with the CSV field position as key
99 99
 	 * @return array List of associative arrays containing the chunked properties
100 100
 	 */
101
-	protected function getMappedChunk( array &$data, array $mapping )
101
+	protected function getMappedChunk(array &$data, array $mapping)
102 102
 	{
103 103
 		$idx = 0;
104 104
 		$map = [];
105 105
 
106
-		foreach( $mapping as $pos => $key )
106
+		foreach ($mapping as $pos => $key)
107 107
 		{
108
-			if( isset( $map[$idx][$key] ) ) {
108
+			if (isset($map[$idx][$key])) {
109 109
 				$idx++;
110 110
 			}
111 111
 
112
-			if( isset( $data[$pos] ) )
112
+			if (isset($data[$pos]))
113 113
 			{
114 114
 				$map[$idx][$key] = $data[$pos];
115
-				unset( $data[$pos] );
115
+				unset($data[$pos]);
116 116
 			}
117 117
 		}
118 118
 
@@ -126,37 +126,37 @@  discard block
 block discarded – undo
126 126
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
127 127
 	 * @return \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface Processor object
128 128
 	 */
129
-	protected function getProcessors( array $mappings )
129
+	protected function getProcessors(array $mappings)
130 130
 	{
131 131
 		$context = $this->getContext();
132 132
 		$config = $context->getConfig();
133
-		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done( $context, [] );
133
+		$object = new \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Done($context, []);
134 134
 
135
-		foreach( $mappings as $type => $mapping )
135
+		foreach ($mappings as $type => $mapping)
136 136
 		{
137
-			if( ctype_alnum( $type ) === false )
137
+			if (ctype_alnum($type) === false)
138 138
 			{
139 139
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type : '<not a string>';
140
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
140
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
141 141
 			}
142 142
 
143
-			$name = $config->get( 'controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard' );
143
+			$name = $config->get('controller/common/coupon/import/csv/processor/' . $type . '/name', 'Standard');
144 144
 
145
-			if( ctype_alnum( $name ) === false )
145
+			if (ctype_alnum($name) === false)
146 146
 			{
147 147
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
148
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
148
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
149 149
 			}
150 150
 
151
-			$classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
151
+			$classname = '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
152 152
 
153
-			if( class_exists( $classname ) === false ) {
154
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
153
+			if (class_exists($classname) === false) {
154
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
155 155
 			}
156 156
 
157
-			$object = new $classname( $context, $mapping, $object );
157
+			$object = new $classname($context, $mapping, $object);
158 158
 
159
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object );
159
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Coupon\\Import\\Csv\\Processor\\Iface', $object);
160 160
 		}
161 161
 
162 162
 		return $object;
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/End/Standard.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Subscription process end' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process end');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Terminates expired subscriptions' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Terminates expired subscriptions');
43 43
 	}
44 44
 
45 45
 
@@ -65,51 +65,51 @@  discard block
 block discarded – undo
65 65
 		 * @since 2018.04
66 66
 		 * @category Developer
67 67
 		 */
68
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
68
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
69 69
 
70
-		$processors = $this->getProcessors( $names );
71
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
70
+		$processors = $this->getProcessors($names);
71
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
72 72
 
73
-		$search = $manager->createSearch( true );
73
+		$search = $manager->createSearch(true);
74 74
 		$expr = [
75
-			$search->compare( '<', 'subscription.dateend', date( 'Y-m-d' ) ),
75
+			$search->compare('<', 'subscription.dateend', date('Y-m-d')),
76 76
 			$search->getConditions(),
77 77
 		];
78
-		$search->setConditions( $search->combine( '&&', $expr ) );
79
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
78
+		$search->setConditions($search->combine('&&', $expr));
79
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
80 80
 
81 81
 		$start = 0;
82 82
 
83 83
 		do
84 84
 		{
85
-			$search->setSlice( $start, 100 );
86
-			$items = $manager->searchItems( $search );
85
+			$search->setSlice($start, 100);
86
+			$items = $manager->searchItems($search);
87 87
 
88
-			foreach( $items as $item )
88
+			foreach ($items as $item)
89 89
 			{
90 90
 				try
91 91
 				{
92
-					foreach( $processors as $processor ) {
93
-						$processor->end( $item );
92
+					foreach ($processors as $processor) {
93
+						$processor->end($item);
94 94
 					}
95 95
 
96
-					if( ( $reason = $item->getReason() ) === null ) {
96
+					if (($reason = $item->getReason()) === null) {
97 97
 						$reason = \Aimeos\MShop\Subscription\Item\Iface::REASON_END;
98 98
 					}
99 99
 
100
-					$manager->saveItem( $item->setReason( $reason )->setStatus( 0 ) );
100
+					$manager->saveItem($item->setReason($reason)->setStatus(0));
101 101
 				}
102
-				catch( \Exception $e )
102
+				catch (\Exception $e)
103 103
 				{
104 104
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
105
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
106
-					$logger->log( $e->getTraceAsString() );
105
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
106
+					$logger->log($e->getTraceAsString());
107 107
 				}
108 108
 			}
109 109
 
110
-			$count = count( $items );
110
+			$count = count($items);
111 111
 			$start += $count;
112 112
 		}
113
-		while( $count === $search->getSliceSize() );
113
+		while ($count === $search->getSliceSize());
114 114
 	}
115 115
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Process/Begin/StanardTest.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -20,49 +20,49 @@  discard block
 block discarded – undo
20 20
 		$aimeos = \TestHelperJobs::getAimeos();
21 21
 		$this->context = \TestHelperJobs::getContext();
22 22
 
23
-		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard( $this->context, $aimeos );
23
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\Begin\Standard($this->context, $aimeos);
24 24
 
25
-		\Aimeos\MShop\Factory::setCache( true );
25
+		\Aimeos\MShop\Factory::setCache(true);
26 26
 	}
27 27
 
28 28
 
29 29
 	protected function tearDown()
30 30
 	{
31
-		\Aimeos\MShop\Factory::setCache( false );
31
+		\Aimeos\MShop\Factory::setCache(false);
32 32
 		\Aimeos\MShop\Factory::clear();
33 33
 
34
-		unset( $this->object, $this->context );
34
+		unset($this->object, $this->context);
35 35
 	}
36 36
 
37 37
 
38 38
 	public function testGetName()
39 39
 	{
40
-		$this->assertEquals( 'Subscription process start', $this->object->getName() );
40
+		$this->assertEquals('Subscription process start', $this->object->getName());
41 41
 	}
42 42
 
43 43
 
44 44
 	public function testGetDescription()
45 45
 	{
46
-		$this->assertEquals( 'Process subscriptions initially', $this->object->getDescription() );
46
+		$this->assertEquals('Process subscriptions initially', $this->object->getDescription());
47 47
 	}
48 48
 
49 49
 
50 50
 	public function testRun()
51 51
 	{
52
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
52
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
53 53
 		$item = $this->getSubscription();
54 54
 
55
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
56
-			->setConstructorArgs( [$this->context] )
57
-			->setMethods( ['searchItems', 'saveItem'] )
55
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
56
+			->setConstructorArgs([$this->context])
57
+			->setMethods(['searchItems', 'saveItem'])
58 58
 			->getMock();
59 59
 
60
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
60
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
61 61
 
62
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
63
-			->will( $this->returnValue( [$item] ) );
62
+		$managerStub->expects($this->once())->method('searchItems')
63
+			->will($this->returnValue([$item]));
64 64
 
65
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
65
+		$managerStub->expects($this->once())->method('saveItem');
66 66
 
67 67
 		$this->object->run();
68 68
 	}
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 
71 71
 	public function testRunException()
72 72
 	{
73
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processors', ['cgroup'] );
74
-		$this->context->getConfig()->set( 'controller/common/subscription/process/processor/cgroup/groupids', ['1'] );
73
+		$this->context->getConfig()->set('controller/common/subscription/process/processors', ['cgroup']);
74
+		$this->context->getConfig()->set('controller/common/subscription/process/processor/cgroup/groupids', ['1']);
75 75
 
76
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
77
-			->setConstructorArgs( [$this->context] )
78
-			->setMethods( ['searchItems', 'saveItem'] )
76
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
77
+			->setConstructorArgs([$this->context])
78
+			->setMethods(['searchItems', 'saveItem'])
79 79
 			->getMock();
80 80
 
81
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
81
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
82 82
 
83
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
84
-			->will( $this->returnValue( [$managerStub->createItem()] ) );
83
+		$managerStub->expects($this->once())->method('searchItems')
84
+			->will($this->returnValue([$managerStub->createItem()]));
85 85
 
86
-		$managerStub->expects( $this->once() )->method( 'saveItem' )
87
-			->will( $this->throwException( new \Exception() ) );
86
+		$managerStub->expects($this->once())->method('saveItem')
87
+			->will($this->throwException(new \Exception()));
88 88
 
89 89
 		$this->object->run();
90 90
 	}
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 
93 93
 	protected function getSubscription()
94 94
 	{
95
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' );
95
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription');
96 96
 
97 97
 		$search = $manager->createSearch();
98
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
98
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
99 99
 
100
-		$items = $manager->searchItems( $search );
100
+		$items = $manager->searchItems($search);
101 101
 
102
-		if( ( $item = reset( $items ) ) !== false ) {
102
+		if (($item = reset($items)) !== false) {
103 103
 			return $item;
104 104
 		}
105 105
 
106
-		throw new \Exception( 'No subscription item found' );
106
+		throw new \Exception('No subscription item found');
107 107
 	}
108 108
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	public function getName()
30 30
 	{
31
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Catalog import CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Catalog import CSV');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Imports new and updates existing categories from CSV files' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Imports new and updates existing categories from CSV files');
43 43
 	}
44 44
 
45 45
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$context = $this->getContext();
55 55
 		$config = $context->getConfig();
56 56
 		$logger = $context->getLogger();
57
-		$domains = array( 'media', 'text' );
57
+		$domains = array('media', 'text');
58 58
 		$mappings = $this->getDefaultMapping();
59 59
 
60 60
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		 * @see controller/common/catalog/import/csv/converter
75 75
 		 * @see controller/common/catalog/import/csv/max-size
76 76
 		 */
77
-		$domains = $config->get( 'controller/common/catalog/import/csv/domains', $domains );
77
+		$domains = $config->get('controller/common/catalog/import/csv/domains', $domains);
78 78
 
79 79
 		/** controller/jobs/catalog/import/csv/domains
80 80
 		 * List of item domain names that should be retrieved along with the catalog items
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		 * @see controller/jobs/catalog/import/csv/backup
95 95
 		 * @see controller/common/catalog/import/csv/max-size
96 96
 		 */
97
-		$domains = $config->get( 'controller/jobs/catalog/import/csv/domains', $domains );
97
+		$domains = $config->get('controller/jobs/catalog/import/csv/domains', $domains);
98 98
 
99 99
 
100 100
 		/** controller/common/catalog/import/csv/mapping
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		 * @see controller/common/catalog/import/csv/converter
123 123
 		 * @see controller/common/catalog/import/csv/max-size
124 124
 		 */
125
-		$mappings = $config->get( 'controller/common/catalog/import/csv/mapping', $mappings );
125
+		$mappings = $config->get('controller/common/catalog/import/csv/mapping', $mappings);
126 126
 
127 127
 		/** controller/jobs/catalog/import/csv/mapping
128 128
 		 * List of mappings between the position in the CSV file and item keys
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		 * @see controller/jobs/catalog/import/csv/backup
143 143
 		 * @see controller/common/catalog/import/csv/max-size
144 144
 		 */
145
-		$mappings = $config->get( 'controller/jobs/catalog/import/csv/mapping', $mappings );
145
+		$mappings = $config->get('controller/jobs/catalog/import/csv/mapping', $mappings);
146 146
 
147 147
 
148 148
 		/** controller/common/catalog/import/csv/converter
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 * @see controller/common/catalog/import/csv/mapping
185 185
 		 * @see controller/common/catalog/import/csv/max-size
186 186
 		 */
187
-		$converters = $config->get( 'controller/common/catalog/import/csv/converter', [] );
187
+		$converters = $config->get('controller/common/catalog/import/csv/converter', []);
188 188
 
189 189
 		/** controller/jobs/catalog/import/csv/converter
190 190
 		 * List of converter names for the values at the position in the CSV file
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		 * @see controller/jobs/catalog/import/csv/backup
205 205
 		 * @see controller/common/catalog/import/csv/max-size
206 206
 		 */
207
-		$converters = $config->get( 'controller/jobs/catalog/import/csv/converter', $converters );
207
+		$converters = $config->get('controller/jobs/catalog/import/csv/converter', $converters);
208 208
 
209 209
 
210 210
 		/** controller/common/catalog/import/csv/max-size
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		 * @see controller/common/catalog/import/csv/mapping
225 225
 		 * @see controller/common/catalog/import/csv/converter
226 226
 		 */
227
-		$maxcnt = (int) $config->get( 'controller/common/catalog/import/csv/max-size', 1000 );
227
+		$maxcnt = (int) $config->get('controller/common/catalog/import/csv/max-size', 1000);
228 228
 
229 229
 
230 230
 		/** controller/jobs/catalog/import/csv/skip-lines
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		 * @see controller/jobs/catalog/import/csv/backup
247 247
 		 * @see controller/common/catalog/import/csv/max-size
248 248
 		 */
249
-		$skiplines = (int) $config->get( 'controller/jobs/catalog/import/csv/skip-lines', 0 );
249
+		$skiplines = (int) $config->get('controller/jobs/catalog/import/csv/skip-lines', 0);
250 250
 
251 251
 
252 252
 		/** controller/jobs/catalog/import/csv/strict
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		 * @see controller/jobs/catalog/import/csv/backup
271 271
 		 * @see controller/common/catalog/import/csv/max-size
272 272
 		 */
273
-		$strict = (bool) $config->get( 'controller/jobs/catalog/import/csv/strict', true );
273
+		$strict = (bool) $config->get('controller/jobs/catalog/import/csv/strict', true);
274 274
 
275 275
 
276 276
 		/** controller/jobs/catalog/import/csv/backup
@@ -303,75 +303,75 @@  discard block
 block discarded – undo
303 303
 		 * @see controller/jobs/catalog/import/csv/strict
304 304
 		 * @see controller/common/catalog/import/csv/max-size
305 305
 		 */
306
-		$backup = $config->get( 'controller/jobs/catalog/import/csv/backup' );
306
+		$backup = $config->get('controller/jobs/catalog/import/csv/backup');
307 307
 
308 308
 
309
-		if( !isset( $mappings['item'] ) || !is_array( $mappings['item'] ) )
309
+		if (!isset($mappings['item']) || !is_array($mappings['item']))
310 310
 		{
311
-			$msg = sprintf( 'Required mapping key "%1$s" is missing or contains no array', 'item' );
312
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
311
+			$msg = sprintf('Required mapping key "%1$s" is missing or contains no array', 'item');
312
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
313 313
 		}
314 314
 
315 315
 		try
316 316
 		{
317 317
 			$procMappings = $mappings;
318
-			unset( $procMappings['item'] );
318
+			unset($procMappings['item']);
319 319
 
320
-			$codePos = $this->getCodePosition( $mappings['item'] );
321
-			$convlist = $this->getConverterList( $converters );
322
-			$processor = $this->getProcessors( $procMappings );
323
-			$catalogMap = $this->getCatalogMap( $domains );
320
+			$codePos = $this->getCodePosition($mappings['item']);
321
+			$convlist = $this->getConverterList($converters);
322
+			$processor = $this->getProcessors($procMappings);
323
+			$catalogMap = $this->getCatalogMap($domains);
324 324
 			$container = $this->getContainer();
325 325
 			$path = $container->getName();
326 326
 
327 327
 
328
-			$msg = sprintf( 'Started catalog import from "%1$s" (%2$s)', $path, __CLASS__ );
329
-			$logger->log( $msg, \Aimeos\MW\Logger\Base::NOTICE );
328
+			$msg = sprintf('Started catalog import from "%1$s" (%2$s)', $path, __CLASS__);
329
+			$logger->log($msg, \Aimeos\MW\Logger\Base::NOTICE);
330 330
 
331
-			foreach( $container as $content )
331
+			foreach ($container as $content)
332 332
 			{
333 333
 				$name = $content->getName();
334 334
 
335
-				for( $i = 0; $i < $skiplines; $i++ ) {
335
+				for ($i = 0; $i < $skiplines; $i++) {
336 336
 					$content->next();
337 337
 				}
338 338
 
339
-				while( ( $data = $this->getData( $content, $maxcnt, $codePos ) ) !== [] )
339
+				while (($data = $this->getData($content, $maxcnt, $codePos)) !== [])
340 340
 				{
341
-					$data = $this->convertData( $convlist, $data );
342
-					$errcnt = $this->import( $catalogMap, $data, $mappings['item'], $processor, $strict );
343
-					$chunkcnt = count( $data );
341
+					$data = $this->convertData($convlist, $data);
342
+					$errcnt = $this->import($catalogMap, $data, $mappings['item'], $processor, $strict);
343
+					$chunkcnt = count($data);
344 344
 
345 345
 					$msg = 'Imported catalog lines from "%1$s": %2$d/%3$d (%4$s)';
346
-					$logger->log( sprintf( $msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
346
+					$logger->log(sprintf($msg, $name, $chunkcnt - $errcnt, $chunkcnt, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
347 347
 
348 348
 					$errors += $errcnt;
349 349
 					$total += $chunkcnt;
350
-					unset( $data );
350
+					unset($data);
351 351
 				}
352 352
 			}
353 353
 
354 354
 			$container->close();
355 355
 		}
356
-		catch( \Exception $e )
356
+		catch (\Exception $e)
357 357
 		{
358
-			$logger->log( 'Catalog import error: ' . $e->getMessage() );
359
-			$logger->log( $e->getTraceAsString() );
358
+			$logger->log('Catalog import error: ' . $e->getMessage());
359
+			$logger->log($e->getTraceAsString());
360 360
 
361
-			throw new \Aimeos\Controller\Jobs\Exception( $e->getMessage() );
361
+			throw new \Aimeos\Controller\Jobs\Exception($e->getMessage());
362 362
 		}
363 363
 
364 364
 		$msg = 'Finished catalog import from "%1$s": %2$d successful, %3$s errors, %4$s total (%5$s)';
365
-		$logger->log( sprintf( $msg, $path, $total - $errors, $errors, $total, __CLASS__ ), \Aimeos\MW\Logger\Base::NOTICE );
365
+		$logger->log(sprintf($msg, $path, $total - $errors, $errors, $total, __CLASS__), \Aimeos\MW\Logger\Base::NOTICE);
366 366
 
367
-		if( $errors > 0 )
367
+		if ($errors > 0)
368 368
 		{
369
-			$msg = sprintf( 'Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total );
370
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
369
+			$msg = sprintf('Invalid catalog lines in "%1$s": %2$d/%3$d', $path, $errors, $total);
370
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
371 371
 		}
372 372
 
373
-		if( !empty( $backup ) && @rename( $path, strftime( $backup ) ) === false ) {
374
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Unable to move imported file' ) );
373
+		if (!empty($backup) && @rename($path, strftime($backup)) === false) {
374
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Unable to move imported file'));
375 375
 		}
376 376
 	}
377 377
 
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 	 * @return integer Position of the "catalog.code" column
384 384
 	 * @throws \Aimeos\Controller\Jobs\Exception If no mapping for "catalog.code" is found
385 385
 	 */
386
-	protected function getCodePosition( array $mapping )
386
+	protected function getCodePosition(array $mapping)
387 387
 	{
388
-		foreach( $mapping as $pos => $key )
388
+		foreach ($mapping as $pos => $key)
389 389
 		{
390
-			if( $key === 'catalog.code' ) {
390
+			if ($key === 'catalog.code') {
391 391
 				return $pos;
392 392
 			}
393 393
 		}
394 394
 
395
-		throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No "catalog.code" column in CSV mapping found' ) );
395
+		throw new \Aimeos\Controller\Jobs\Exception(sprintf('No "catalog.code" column in CSV mapping found'));
396 396
 	}
397 397
 
398 398
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		 * @see controller/jobs/catalog/import/csv/container/content
428 428
 		 * @see controller/jobs/catalog/import/csv/container/options
429 429
 		 */
430
-		$location = $config->get( 'controller/jobs/catalog/import/csv/location' );
430
+		$location = $config->get('controller/jobs/catalog/import/csv/location');
431 431
 
432 432
 		/** controller/jobs/catalog/import/csv/container/type
433 433
 		 * Nave of the container type to read the data from
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		 * @see controller/jobs/catalog/import/csv/container/content
451 451
 		 * @see controller/jobs/catalog/import/csv/container/options
452 452
 		 */
453
-		$container = $config->get( 'controller/jobs/catalog/import/csv/container/type', 'Directory' );
453
+		$container = $config->get('controller/jobs/catalog/import/csv/container/type', 'Directory');
454 454
 
455 455
 		/** controller/jobs/catalog/import/csv/container/content
456 456
 		 * Name of the content type inside the container to read the data from
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 		 * @see controller/jobs/catalog/import/csv/container/type
472 472
 		 * @see controller/jobs/catalog/import/csv/container/options
473 473
 		 */
474
-		$content = $config->get( 'controller/jobs/catalog/import/csv/container/content', 'CSV' );
474
+		$content = $config->get('controller/jobs/catalog/import/csv/container/content', 'CSV');
475 475
 
476 476
 		/** controller/jobs/catalog/import/csv/container/options
477 477
 		 * List of file container options for the catalog import files
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
 		 * @see controller/jobs/catalog/import/csv/container/content
490 490
 		 * @see controller/jobs/catalog/import/csv/container/type
491 491
 		 */
492
-		$options = $config->get( 'controller/jobs/catalog/import/csv/container/options', [] );
492
+		$options = $config->get('controller/jobs/catalog/import/csv/container/options', []);
493 493
 
494
-		if( $location === null )
494
+		if ($location === null)
495 495
 		{
496
-			$msg = sprintf( 'Required configuration for "%1$s" is missing', 'controller/jobs/catalog/import/csv/location' );
497
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
496
+			$msg = sprintf('Required configuration for "%1$s" is missing', 'controller/jobs/catalog/import/csv/location');
497
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
498 498
 		}
499 499
 
500
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
500
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
501 501
 	}
502 502
 
503 503
 
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 	 * @param array $domains List of domain names whose items should be fetched too
508 508
 	 * @return array Associative list of catalog codes as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface as values
509 509
 	 */
510
-	protected function getCatalogMap( array $domains )
510
+	protected function getCatalogMap(array $domains)
511 511
 	{
512 512
 		$map = [];
513
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' );
514
-		$search = $manager->createSearch()->setSlice( 0, 0x7fffffff );
513
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog');
514
+		$search = $manager->createSearch()->setSlice(0, 0x7fffffff);
515 515
 
516
-		foreach( $manager->searchItems( $search, $domains ) as $item ) {
516
+		foreach ($manager->searchItems($search, $domains) as $item) {
517 517
 			$map[$item->getCode()] = $item;
518 518
 		}
519 519
 
@@ -529,23 +529,23 @@  discard block
 block discarded – undo
529 529
 	 * @param string $code Catalog item code of the parent category
530 530
 	 * @return string|null ID of the parent category or null for top level nodes
531 531
 	 */
532
-	protected function getParentId( array $catalogMap, array $map, $code )
532
+	protected function getParentId(array $catalogMap, array $map, $code)
533 533
 	{
534
-		if( !isset( $map['catalog.parent'] ) )
534
+		if (!isset($map['catalog.parent']))
535 535
 		{
536
-			$msg = sprintf( 'Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code );
537
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
536
+			$msg = sprintf('Required column "%1$s" not found for code "%2$s"', 'catalog.parent', $code);
537
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
538 538
 		}
539 539
 
540
-		$parent = trim( $map['catalog.parent'] );
540
+		$parent = trim($map['catalog.parent']);
541 541
 
542
-		if( $parent != '' && !isset( $catalogMap[$parent] ) )
542
+		if ($parent != '' && !isset($catalogMap[$parent]))
543 543
 		{
544
-			$msg = sprintf( 'Parent node for code "%1$s" not found', $parent );
545
-			throw new \Aimeos\Controller\Jobs\Exception( $msg );
544
+			$msg = sprintf('Parent node for code "%1$s" not found', $parent);
545
+			throw new \Aimeos\Controller\Jobs\Exception($msg);
546 546
 		}
547 547
 
548
-		return ( $parent != '' ? $catalogMap[$parent]->getId() : null );
548
+		return ($parent != '' ? $catalogMap[$parent]->getId() : null);
549 549
 	}
550 550
 
551 551
 
@@ -560,65 +560,65 @@  discard block
 block discarded – undo
560 560
 	 * @return integer Number of catalogs that couldn't be imported
561 561
 	 * @throws \Aimeos\Controller\Jobs\Exception
562 562
 	 */
563
-	protected function import( array &$catalogMap, array $data, array $mapping,
564
-		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict )
563
+	protected function import(array &$catalogMap, array $data, array $mapping,
564
+		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor, $strict)
565 565
 	{
566 566
 		$errors = 0;
567 567
 		$context = $this->getContext();
568
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'catalog' );
568
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'catalog');
569 569
 
570
-		foreach( $data as $code => $list )
570
+		foreach ($data as $code => $list)
571 571
 		{
572 572
 			$manager->begin();
573 573
 
574 574
 			try
575 575
 			{
576
-				$code = trim( $code );
576
+				$code = trim($code);
577 577
 
578
-				if( isset( $catalogMap[$code] )  ) {
578
+				if (isset($catalogMap[$code])) {
579 579
 					$catalogItem = $catalogMap[$code];
580 580
 				} else {
581 581
 					$catalogItem = $manager->createItem();
582 582
 				}
583 583
 
584
-				$map = $this->getMappedChunk( $list, $mapping );
584
+				$map = $this->getMappedChunk($list, $mapping);
585 585
 
586
-				if( isset( $map[0] ) )
586
+				if (isset($map[0]))
587 587
 				{
588 588
 					$map = $map[0]; // there can only be one chunk for the base catalog data
589
-					$parentid = $this->getParentId( $catalogMap, $map, $code );
590
-					$catalogItem->fromArray( $this->addItemDefaults( $map ) );
589
+					$parentid = $this->getParentId($catalogMap, $map, $code);
590
+					$catalogItem->fromArray($this->addItemDefaults($map));
591 591
 
592
-					if( isset( $catalogMap[$code] ) )
592
+					if (isset($catalogMap[$code]))
593 593
 					{
594
-						$manager->moveItem( $catalogItem->getId(), $catalogItem->getParentId(), $parentid );
595
-						$catalogItem = $manager->saveItem( $catalogItem );
594
+						$manager->moveItem($catalogItem->getId(), $catalogItem->getParentId(), $parentid);
595
+						$catalogItem = $manager->saveItem($catalogItem);
596 596
 					}
597 597
 					else
598 598
 					{
599
-						$catalogItem = $manager->insertItem( $catalogItem, $parentid );
599
+						$catalogItem = $manager->insertItem($catalogItem, $parentid);
600 600
 					}
601 601
 
602
-					$list = $processor->process( $catalogItem, $list );
602
+					$list = $processor->process($catalogItem, $list);
603 603
 					$catalogMap[$code] = $catalogItem;
604 604
 
605
-					$manager->saveItem( $catalogItem );
605
+					$manager->saveItem($catalogItem);
606 606
 				}
607 607
 
608 608
 				$manager->commit();
609 609
 			}
610
-			catch( \Exception $e )
610
+			catch (\Exception $e)
611 611
 			{
612 612
 				$manager->rollback();
613 613
 
614
-				$msg = sprintf( 'Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage() );
615
-				$context->getLogger()->log( $msg );
614
+				$msg = sprintf('Unable to import catalog with code "%1$s": %2$s', $code, $e->getMessage());
615
+				$context->getLogger()->log($msg);
616 616
 
617 617
 				$errors++;
618 618
 			}
619 619
 
620
-			if( $strict && !empty( $list ) ) {
621
-				$context->getLogger()->log( 'Not imported: ' . print_r( $list, true ) );
620
+			if ($strict && !empty($list)) {
621
+				$context->getLogger()->log('Not imported: ' . print_r($list, true));
622 622
 			}
623 623
 		}
624 624
 
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 	 * @param array $list Associative list of domain item keys and their values, e.g. "catalog.status" => 1
633 633
 	 * @return array Given associative list enriched by default values if they were not already set
634 634
 	 */
635
-	protected function addItemDefaults( array $list )
635
+	protected function addItemDefaults(array $list)
636 636
 	{
637
-		if( !isset( $list['catalog.status'] ) ) {
637
+		if (!isset($list['catalog.status'])) {
638 638
 			$list['catalog.status'] = 1;
639 639
 		}
640 640
 
Please login to merge, or discard this patch.