Completed
Push — master ( 08fedb...6dd458 )
by Aimeos
05:10
created
controller/common/tests/Controller/Common/Catalog/Import/Csv/BaseTest.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,77 +16,77 @@  discard block
 block discarded – undo
16 16
 
17 17
 	protected function setUp()
18 18
 	{
19
-		\Aimeos\MShop\Factory::setCache( true );
19
+		\Aimeos\MShop\Factory::setCache(true);
20 20
 
21 21
 		$context = \TestHelperCntl::getContext();
22 22
 		$aimeos = \TestHelperCntl::getAimeos();
23 23
 
24
-		$this->object = new TestAbstract( $context, $aimeos );
24
+		$this->object = new TestAbstract($context, $aimeos);
25 25
 	}
26 26
 
27 27
 
28 28
 	protected function tearDown()
29 29
 	{
30
-		\Aimeos\MShop\Factory::setCache( false );
30
+		\Aimeos\MShop\Factory::setCache(false);
31 31
 		\Aimeos\MShop\Factory::clear();
32 32
 	}
33 33
 
34 34
 
35 35
 	public function testGetCacheInvalidType()
36 36
 	{
37
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
38
-		$this->object->getCachePublic( '$' );
37
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
38
+		$this->object->getCachePublic('$');
39 39
 	}
40 40
 
41 41
 
42 42
 	public function testGetCacheInvalidClass()
43 43
 	{
44
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
45
-		$this->object->getCachePublic( 'unknown' );
44
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
45
+		$this->object->getCachePublic('unknown');
46 46
 	}
47 47
 
48 48
 
49 49
 	public function testGetProcessors()
50 50
 	{
51
-		$processor = $this->object->getProcessorsPublic( array( 'media' => [] ) );
51
+		$processor = $this->object->getProcessorsPublic(array('media' => []));
52 52
 
53
-		$this->assertInstanceOf( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $processor );
53
+		$this->assertInstanceOf('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $processor);
54 54
 	}
55 55
 
56 56
 
57 57
 	public function testGetProcessorsInvalidType()
58 58
 	{
59
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
60
-		$this->object->getProcessorsPublic( array( '$' => [] ) );
59
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
60
+		$this->object->getProcessorsPublic(array('$' => []));
61 61
 	}
62 62
 
63 63
 
64 64
 	public function testGetProcessorsInvalidClass()
65 65
 	{
66
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
67
-		$this->object->getProcessorsPublic( array( 'unknown' => [] ) );
66
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
67
+		$this->object->getProcessorsPublic(array('unknown' => []));
68 68
 	}
69 69
 
70 70
 
71 71
 	public function testGetProcessorsInvalidInterface()
72 72
 	{
73
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
74
-		$this->object->getProcessorsPublic( array( 'unknown' => [] ) );
73
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
74
+		$this->object->getProcessorsPublic(array('unknown' => []));
75 75
 	}
76 76
 
77 77
 
78 78
 	public function testGetTypeId()
79 79
 	{
80
-		$typeid = $this->object->getTypeIdPublic( 'text/type', 'catalog', 'name' );
80
+		$typeid = $this->object->getTypeIdPublic('text/type', 'catalog', 'name');
81 81
 
82
-		$this->assertNotEquals( null, $typeid );
82
+		$this->assertNotEquals(null, $typeid);
83 83
 	}
84 84
 
85 85
 
86 86
 	public function testGetTypeIdUnknown()
87 87
 	{
88
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
89
-		$this->object->getTypeIdPublic( 'text/type', 'catalog', 'unknown' );
88
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
89
+		$this->object->getTypeIdPublic('text/type', 'catalog', 'unknown');
90 90
 	}
91 91
 }
92 92
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
 class TestAbstract
95 95
 	extends \Aimeos\Controller\Common\Catalog\Import\Csv\Base
96 96
 {
97
-	public function getCachePublic( $type, $name = null )
97
+	public function getCachePublic($type, $name = null)
98 98
 	{
99
-		return $this->getCache( $type, $name );
99
+		return $this->getCache($type, $name);
100 100
 	}
101 101
 
102 102
 
103
-	public function getProcessorsPublic( array $mappings )
103
+	public function getProcessorsPublic(array $mappings)
104 104
 	{
105
-		return $this->getProcessors( $mappings );
105
+		return $this->getProcessors($mappings);
106 106
 	}
107 107
 
108 108
 
109
-	public function getTypeIdPublic( $path, $domain, $code )
109
+	public function getTypeIdPublic($path, $domain, $code)
110 110
 	{
111
-		return $this->getTypeId( $path, $domain, $code );
111
+		return $this->getTypeId($path, $domain, $code);
112 112
 	}
113 113
 }
114 114
 
Please login to merge, or discard this patch.
common/tests/Controller/Common/Product/Import/Csv/Processor/DoneTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 
18 18
 	protected function setUp()
19 19
 	{
20
-		\Aimeos\MShop\Factory::setCache( true );
20
+		\Aimeos\MShop\Factory::setCache(true);
21 21
 
22 22
 		$this->context = \TestHelperCntl::getContext();
23
-		$this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] );
23
+		$this->object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($this->context, []);
24 24
 	}
25 25
 
26 26
 
27 27
 	protected function tearDown()
28 28
 	{
29
-		\Aimeos\MShop\Factory::setCache( false );
29
+		\Aimeos\MShop\Factory::setCache(false);
30 30
 		\Aimeos\MShop\Factory::clear();
31 31
 
32 32
 		$this->object = null;
@@ -35,10 +35,10 @@  discard block
 block discarded – undo
35 35
 
36 36
 	public function testProcess()
37 37
 	{
38
-		$product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->createItem();
38
+		$product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->createItem();
39 39
 
40
-		$result = $this->object->process( $product, array( 'test' ) );
40
+		$result = $this->object->process($product, array('test'));
41 41
 
42
-		$this->assertEquals( array( 'test' ), $result );
42
+		$this->assertEquals(array('test'), $result);
43 43
 	}
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
common/src/Controller/Common/Catalog/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\Catalog\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\Catalog\Import\Csv\Processor\Iface $processor = null )
30
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
31
+		\Aimeos\Controller\Common\Catalog\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\Catalog\Item\Iface $catalog, array $data )
43
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data)
44 44
 	{
45 45
 		return $data;
46 46
 	}
Please login to merge, or discard this patch.
common/src/Controller/Common/Catalog/Import/Csv/Processor/Iface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
27 27
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor Decorated processor
28 28
 	 */
29
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
-		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor = null );
29
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
30
+		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $processor = null);
31 31
 
32 32
 
33 33
 	/**
@@ -37,5 +37,5 @@  discard block
 block discarded – undo
37 37
 	 * @param array $data List of CSV fields with position as key and data as value
38 38
 	 * @return array List of data which hasn't been imported
39 39
 	 */
40
-	public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data );
40
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data);
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
controller/common/src/Controller/Common/Catalog/Import/Csv/Cache/Iface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
26 26
 	 */
27
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context );
27
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context);
28 28
 
29 29
 	/**
30 30
 	 * Returns the item or ID for the given code
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 * @param string|null $type Item type if used and required
34 34
 	 * @return \Aimeos\MShop\Common\Item\Iface|string|null Item object, unique ID or null if not found
35 35
 	 */
36
-	public function get( $code, $type = null );
36
+	public function get($code, $type = null);
37 37
 
38 38
 	/**
39 39
 	 * Adds the item or ID to the cache
40 40
 	 *
41 41
 	 * @param \Aimeos\MShop\Common\Item\Iface $item Item object
42 42
 	 */
43
-	public function set( \Aimeos\MShop\Common\Item\Iface $item );
43
+	public function set(\Aimeos\MShop\Common\Item\Iface $item);
44 44
 }
Please login to merge, or discard this patch.
controller/common/src/Controller/Common/Catalog/Import/Csv/Cache/Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 *
28 28
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
29 29
 	 */
30
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
30
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context)
31 31
 	{
32 32
 		$this->context = $context;
33 33
 	}
Please login to merge, or discard this patch.
controller/jobs/tests/Controller/Jobs/Catalog/Import/Csv/FactoryTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 		$context = \TestHelperJobs::getContext();
17 17
 		$aimeos = \TestHelperJobs::getAimeos();
18 18
 
19
-		$obj = \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos );
20
-		$this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj);
19
+		$obj = \Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos);
20
+		$this->assertInstanceOf('\\Aimeos\\Controller\\Jobs\\Iface', $obj);
21 21
 	}
22 22
 
23 23
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 		$context = \TestHelperJobs::getContext();
27 27
 		$aimeos = \TestHelperJobs::getAimeos();
28 28
 
29
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
30
-		\Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos, 'Wrong$$$Name' );
29
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
30
+		\Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos, 'Wrong$$$Name');
31 31
 	}
32 32
 
33 33
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 		$context = \TestHelperJobs::getContext();
37 37
 		$aimeos = \TestHelperJobs::getAimeos();
38 38
 
39
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
40
-		\Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos, 'WrongClass' );
39
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
40
+		\Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos, 'WrongClass');
41 41
 	}
42 42
 
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$context = \TestHelperJobs::getContext();
47 47
 		$aimeos = \TestHelperJobs::getAimeos();
48 48
 
49
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
50
-		\Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController( $context, $aimeos, 'Factory' );
49
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
50
+		\Aimeos\Controller\Jobs\Catalog\Import\Csv\Factory::createController($context, $aimeos, 'Factory');
51 51
 	}
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Factory.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string|null $name Name of the controller or "Standard" if null
30 30
 	 * @return \Aimeos\Controller\Jobs\Iface New controller object
31 31
 	 */
32
-	public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null )
32
+	public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null)
33 33
 	{
34 34
 		/** controller/jobs/catalog/import/csv/name
35 35
 		 * Class name of the used catalog suggestions scheduler controller implementation
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 		 * @since 2018.04
65 65
 		 * @category Developer
66 66
 		 */
67
-		if ( $name === null ) {
67
+		if ($name === null) {
68 68
 			$name = $context->getConfig()->get('controller/jobs/catalog/import/csv/name', 'Standard');
69 69
 		}
70 70
 
71
-		if ( ctype_alnum($name) === false )
71
+		if (ctype_alnum($name) === false)
72 72
 		{
73 73
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Catalog\\Import\\Csv\\' . $name : '<not a string>';
74
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
74
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
75 75
 		}
76 76
 
77 77
 		$iface = '\\Aimeos\\Controller\\Jobs\\Iface';
78 78
 		$classname = '\\Aimeos\\Controller\\Jobs\\Catalog\\Import\\Csv\\' . $name;
79 79
 
80
-		$controller = self::createControllerBase( $context, $aimeos, $classname, $iface );
80
+		$controller = self::createControllerBase($context, $aimeos, $classname, $iface);
81 81
 
82 82
 		/** controller/jobs/catalog/import/csv/decorators/excludes
83 83
 		 * Excludes decorators added by the "common" option from the catalog import CSV job controller
@@ -154,6 +154,6 @@  discard block
 block discarded – undo
154 154
 		 * @see controller/jobs/catalog/import/csv/decorators/excludes
155 155
 		 * @see controller/jobs/catalog/import/csv/decorators/global
156 156
 		 */
157
-		return self::addControllerDecorators( $context, $aimeos, $controller, 'catalog/import/csv' );
157
+		return self::addControllerDecorators($context, $aimeos, $controller, 'catalog/import/csv');
158 158
 	}
159 159
 }
160 160
\ No newline at end of file
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Catalog/Import/Csv/Standard.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -352,8 +352,7 @@  discard block
 block discarded – undo
352 352
 			}
353 353
 
354 354
 			$container->close();
355
-		}
356
-		catch( \Exception $e )
355
+		} catch( \Exception $e )
357 356
 		{
358 357
 			$logger->log( 'Catalog import error: ' . $e->getMessage() );
359 358
 			$logger->log( $e->getTraceAsString() );
@@ -583,8 +582,7 @@  discard block
 block discarded – undo
583 582
 					{
584 583
 						$manager->moveItem( $catalogItem->getId(), $catalogItem->getParentId(), $parentid );
585 584
 						$catalogItem = $manager->saveItem( $catalogItem );
586
-					}
587
-					else
585
+					} else
588 586
 					{
589 587
 						$catalogItem = $manager->insertItem( $catalogItem, $parentid );
590 588
 					}
@@ -594,8 +592,7 @@  discard block
 block discarded – undo
594 592
 				}
595 593
 
596 594
 				$manager->commit();
597
-			}
598
-			catch( \Exception $e )
595
+			} catch( \Exception $e )
599 596
 			{
600 597
 				$manager->rollback();
601 598
 
Please login to merge, or discard this 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.