Completed
Push — master ( c4b4dc...672c0d )
by Aimeos
9s
created
tests/Controller/Common/Product/Import/Csv/Processor/Price/StandardTest.php 1 patch
Spacing   +94 added lines, -94 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->endpoint = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $this->context, [] );
23
+		$this->endpoint = 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
 
@@ -57,38 +57,38 @@  discard block
 block discarded – undo
57 57
 			8 => 1,
58 58
 		);
59 59
 
60
-		$product = $this->create( 'job_csv_test' );
60
+		$product = $this->create('job_csv_test');
61 61
 
62
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
63
-		$object->process( $product, $data );
62
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
63
+		$object->process($product, $data);
64 64
 
65
-		$product = $this->get( 'job_csv_test' );
66
-		$this->delete( $product );
65
+		$product = $this->get('job_csv_test');
66
+		$this->delete($product);
67 67
 
68 68
 
69 69
 		$listItems = $product->getListItems();
70
-		$listItem = reset( $listItems );
70
+		$listItem = reset($listItems);
71 71
 
72
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
73
-		$this->assertEquals( 1, count( $listItems ) );
72
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
73
+		$this->assertEquals(1, count($listItems));
74 74
 
75
-		$this->assertEquals( 1, $listItem->getStatus() );
76
-		$this->assertEquals( 0, $listItem->getPosition() );
77
-		$this->assertEquals( 'price', $listItem->getDomain() );
78
-		$this->assertEquals( 'default', $listItem->getType() );
75
+		$this->assertEquals(1, $listItem->getStatus());
76
+		$this->assertEquals(0, $listItem->getPosition());
77
+		$this->assertEquals('price', $listItem->getDomain());
78
+		$this->assertEquals('default', $listItem->getType());
79 79
 
80 80
 		$refItem = $listItem->getRefItem();
81 81
 
82
-		$this->assertEquals( 1, $refItem->getStatus() );
83
-		$this->assertEquals( 'default', $refItem->getType() );
84
-		$this->assertEquals( 'product', $refItem->getDomain() );
85
-		$this->assertEquals( 'EUR 1.00', $refItem->getLabel() );
86
-		$this->assertEquals( 5, $refItem->getQuantity() );
87
-		$this->assertEquals( '1.00', $refItem->getValue() );
88
-		$this->assertEquals( '0.20', $refItem->getCosts() );
89
-		$this->assertEquals( '0.10', $refItem->getRebate() );
90
-		$this->assertEquals( '20.00', $refItem->getTaxrate() );
91
-		$this->assertEquals( 1, $refItem->getStatus() );
82
+		$this->assertEquals(1, $refItem->getStatus());
83
+		$this->assertEquals('default', $refItem->getType());
84
+		$this->assertEquals('product', $refItem->getDomain());
85
+		$this->assertEquals('EUR 1.00', $refItem->getLabel());
86
+		$this->assertEquals(5, $refItem->getQuantity());
87
+		$this->assertEquals('1.00', $refItem->getValue());
88
+		$this->assertEquals('0.20', $refItem->getCosts());
89
+		$this->assertEquals('0.10', $refItem->getRebate());
90
+		$this->assertEquals('20.00', $refItem->getTaxrate());
91
+		$this->assertEquals(1, $refItem->getStatus());
92 92
 	}
93 93
 
94 94
 
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 			3 => '4.00',
109 109
 		);
110 110
 
111
-		$product = $this->create( 'job_csv_test' );
111
+		$product = $this->create('job_csv_test');
112 112
 
113
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
114
-		$object->process( $product, $data );
113
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
114
+		$object->process($product, $data);
115 115
 
116
-		$product = $this->get( 'job_csv_test' );
117
-		$this->delete( $product );
116
+		$product = $this->get('job_csv_test');
117
+		$this->delete($product);
118 118
 
119 119
 
120 120
 		$pos = 0;
121 121
 		$listItems = $product->getListItems();
122 122
 
123
-		$this->assertEquals( 4, count( $listItems ) );
123
+		$this->assertEquals(4, count($listItems));
124 124
 
125
-		foreach( $listItems as $listItem )
125
+		foreach ($listItems as $listItem)
126 126
 		{
127
-			$this->assertEquals( $data[$pos], $listItem->getRefItem()->getValue() );
127
+			$this->assertEquals($data[$pos], $listItem->getRefItem()->getValue());
128 128
 			$pos++;
129 129
 		}
130 130
 	}
@@ -144,26 +144,26 @@  discard block
 block discarded – undo
144 144
 			0 => '2.00',
145 145
 		);
146 146
 
147
-		$product = $this->create( 'job_csv_test' );
147
+		$product = $this->create('job_csv_test');
148 148
 
149
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
150
-		$object->process( $product, $data );
149
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
150
+		$object->process($product, $data);
151 151
 
152
-		$product = $this->get( 'job_csv_test' );
152
+		$product = $this->get('job_csv_test');
153 153
 
154
-		$object->process( $product, $dataUpdate );
154
+		$object->process($product, $dataUpdate);
155 155
 
156
-		$product = $this->get( 'job_csv_test' );
157
-		$this->delete( $product );
156
+		$product = $this->get('job_csv_test');
157
+		$this->delete($product);
158 158
 
159 159
 
160 160
 		$listItems = $product->getListItems();
161
-		$listItem = reset( $listItems );
161
+		$listItem = reset($listItems);
162 162
 
163
-		$this->assertEquals( 1, count( $listItems ) );
164
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
163
+		$this->assertEquals(1, count($listItems));
164
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
165 165
 
166
-		$this->assertEquals( '2.00', $listItem->getRefItem()->getValue() );
166
+		$this->assertEquals('2.00', $listItem->getRefItem()->getValue());
167 167
 	}
168 168
 
169 169
 
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
 			0 => '1.00',
178 178
 		);
179 179
 
180
-		$product = $this->create( 'job_csv_test' );
180
+		$product = $this->create('job_csv_test');
181 181
 
182
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
183
-		$object->process( $product, $data );
182
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
183
+		$object->process($product, $data);
184 184
 
185
-		$product = $this->get( 'job_csv_test' );
185
+		$product = $this->get('job_csv_test');
186 186
 
187
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, [], $this->endpoint );
188
-		$object->process( $product, [] );
187
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, [], $this->endpoint);
188
+		$object->process($product, []);
189 189
 
190
-		$product = $this->get( 'job_csv_test' );
191
-		$this->delete( $product );
190
+		$product = $this->get('job_csv_test');
191
+		$this->delete($product);
192 192
 
193 193
 
194 194
 		$listItems = $product->getListItems();
195 195
 
196
-		$this->assertEquals( 0, count( $listItems ) );
196
+		$this->assertEquals(0, count($listItems));
197 197
 	}
198 198
 
199 199
 
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
 			1 => '',
210 210
 		);
211 211
 
212
-		$product = $this->create( 'job_csv_test' );
212
+		$product = $this->create('job_csv_test');
213 213
 
214
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
215
-		$object->process( $product, $data );
214
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
215
+		$object->process($product, $data);
216 216
 
217
-		$product = $this->get( 'job_csv_test' );
218
-		$this->delete( $product );
217
+		$product = $this->get('job_csv_test');
218
+		$this->delete($product);
219 219
 
220 220
 
221 221
 		$listItems = $product->getListItems();
222 222
 
223
-		$this->assertEquals( 1, count( $listItems ) );
223
+		$this->assertEquals(1, count($listItems));
224 224
 	}
225 225
 
226 226
 
@@ -240,82 +240,82 @@  discard block
 block discarded – undo
240 240
 			3 => 'default',
241 241
 		);
242 242
 
243
-		$this->context->getConfig()->set( 'controller/common/product/import/csv/processor/price/listtypes', array( 'default' ) );
243
+		$this->context->getConfig()->set('controller/common/product/import/csv/processor/price/listtypes', array('default'));
244 244
 
245
-		$product = $this->create( 'job_csv_test' );
245
+		$product = $this->create('job_csv_test');
246 246
 
247
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard( $this->context, $mapping, $this->endpoint );
248
-		$object->process( $product, $data );
247
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Price\Standard($this->context, $mapping, $this->endpoint);
248
+		$object->process($product, $data);
249 249
 
250
-		$product = $this->get( 'job_csv_test' );
251
-		$this->delete( $product );
250
+		$product = $this->get('job_csv_test');
251
+		$this->delete($product);
252 252
 
253 253
 
254 254
 		$listItems = $product->getListItems();
255
-		$listItem = reset( $listItems );
255
+		$listItem = reset($listItems);
256 256
 
257
-		$this->assertEquals( 1, count( $listItems ) );
258
-		$this->assertInstanceOf( '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem );
257
+		$this->assertEquals(1, count($listItems));
258
+		$this->assertInstanceOf('\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface', $listItem);
259 259
 
260
-		$this->assertEquals( 'default', $listItem->getType() );
261
-		$this->assertEquals( '2.00', $listItem->getRefItem()->getValue() );
260
+		$this->assertEquals('default', $listItem->getType());
261
+		$this->assertEquals('2.00', $listItem->getRefItem()->getValue());
262 262
 	}
263 263
 
264 264
 
265 265
 	/**
266 266
 	 * @param string $code
267 267
 	 */
268
-	protected function create( $code )
268
+	protected function create($code)
269 269
 	{
270
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
271
-		$typeManager = $manager->getSubManager( 'type' );
270
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
271
+		$typeManager = $manager->getSubManager('type');
272 272
 
273 273
 		$typeSearch = $typeManager->createSearch();
274
-		$typeSearch->setConditions( $typeSearch->compare( '==', 'product.type.code', 'default' ) );
275
-		$typeResult = $typeManager->searchItems( $typeSearch );
274
+		$typeSearch->setConditions($typeSearch->compare('==', 'product.type.code', 'default'));
275
+		$typeResult = $typeManager->searchItems($typeSearch);
276 276
 
277
-		if( ( $typeItem = reset( $typeResult ) ) === false ) {
278
-			throw new \RuntimeException( 'No product type "default" found' );
277
+		if (($typeItem = reset($typeResult)) === false) {
278
+			throw new \RuntimeException('No product type "default" found');
279 279
 		}
280 280
 
281 281
 		$item = $manager->createItem();
282
-		$item->setTypeid( $typeItem->getId() );
283
-		$item->setCode( $code );
282
+		$item->setTypeid($typeItem->getId());
283
+		$item->setCode($code);
284 284
 
285
-		return $manager->saveItem( $item );
285
+		return $manager->saveItem($item);
286 286
 	}
287 287
 
288 288
 
289
-	protected function delete( \Aimeos\MShop\Product\Item\Iface $product )
289
+	protected function delete(\Aimeos\MShop\Product\Item\Iface $product)
290 290
 	{
291
-		$priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager( $this->context );
292
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
293
-		$listManager = $manager->getSubManager( 'lists' );
291
+		$priceManager = \Aimeos\MShop\Price\Manager\Factory::createManager($this->context);
292
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
293
+		$listManager = $manager->getSubManager('lists');
294 294
 
295
-		foreach( $product->getListItems('price') as $listItem )
295
+		foreach ($product->getListItems('price') as $listItem)
296 296
 		{
297
-			$priceManager->deleteItem( $listItem->getRefItem()->getId() );
298
-			$listManager->deleteItem( $listItem->getId() );
297
+			$priceManager->deleteItem($listItem->getRefItem()->getId());
298
+			$listManager->deleteItem($listItem->getId());
299 299
 		}
300 300
 
301
-		$manager->deleteItem( $product->getId() );
301
+		$manager->deleteItem($product->getId());
302 302
 	}
303 303
 
304 304
 
305 305
 	/**
306 306
 	 * @param string $code
307 307
 	 */
308
-	protected function get( $code )
308
+	protected function get($code)
309 309
 	{
310
-		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( $this->context );
310
+		$manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
311 311
 
312 312
 		$search = $manager->createSearch();
313
-		$search->setConditions( $search->compare( '==', 'product.code', $code ) );
313
+		$search->setConditions($search->compare('==', 'product.code', $code));
314 314
 
315
-		$result = $manager->searchItems( $search, array('price') );
315
+		$result = $manager->searchItems($search, array('price'));
316 316
 
317
-		if( ( $item = reset( $result ) ) === false ) {
318
-			throw new \RuntimeException( sprintf( 'No product item for code "%1$s"', $code ) );
317
+		if (($item = reset($result)) === false) {
318
+			throw new \RuntimeException(sprintf('No product item for code "%1$s"', $code));
319 319
 		}
320 320
 
321 321
 		return $item;
Please login to merge, or discard this patch.
src/Controller/Common/Catalog/Import/Csv/Processor/Media/Standard.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50 50
 		/** controller/common/catalog/import/csv/processor/media/listtypes
51 51
 		 * Names of the catalog list types for media that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/catalog/import/csv/processor/price/listtypes
67 67
 		 * @see controller/common/catalog/import/csv/processor/text/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/catalog/import/csv/processor/media/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/catalog/import/csv/processor/media/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,45 +77,45 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data )
80
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data)
81 81
 	{
82 82
 		$context = $this->getContext();
83
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'media' );
84
-		$listManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' );
85
-		$separator = $context->getConfig()->get( 'controller/common/catalog/import/csv/separator', "\n" );
83
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'media');
84
+		$listManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists');
85
+		$separator = $context->getConfig()->get('controller/common/catalog/import/csv/separator', "\n");
86 86
 
87 87
 		$manager->begin();
88 88
 
89 89
 		try
90 90
 		{
91 91
 			$delete = $listMap = [];
92
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
93
-			$listItems = $catalog->getListItems( 'media', $this->listTypes );
92
+			$map = $this->getMappedChunk($data, $this->getMapping());
93
+			$listItems = $catalog->getListItems('media', $this->listTypes);
94 94
 
95
-			foreach( $listItems as $listItem )
95
+			foreach ($listItems as $listItem)
96 96
 			{
97
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
98
-					$listMap[ $refItem->getUrl() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
97
+				if (($refItem = $listItem->getRefItem()) !== null) {
98
+					$listMap[$refItem->getUrl()][$refItem->getType()][$listItem->getType()] = $listItem;
99 99
 				}
100 100
 			}
101 101
 
102
-			foreach( $map as $pos => $list )
102
+			foreach ($map as $pos => $list)
103 103
 			{
104
-				if( $this->checkEntry( $list ) === false ) {
104
+				if ($this->checkEntry($list) === false) {
105 105
 					continue;
106 106
 				}
107 107
 
108
-				$urls = explode( $separator, $list['media.url'] );
109
-				$type = $this->getValue( $list, 'media.type', 'default' );
110
-				$typecode = $this->getValue( $list, 'catalog.lists.type', 'default' );
108
+				$urls = explode($separator, $list['media.url']);
109
+				$type = $this->getValue($list, 'media.type', 'default');
110
+				$typecode = $this->getValue($list, 'catalog.lists.type', 'default');
111 111
 
112
-				foreach( $urls as $url )
112
+				foreach ($urls as $url)
113 113
 				{
114
-					if( isset( $listMap[$url][$type][$typecode] ) )
114
+					if (isset($listMap[$url][$type][$typecode]))
115 115
 					{
116 116
 						$listItem = $listMap[$url][$type][$typecode];
117 117
 						$refItem = $listItem->getRefItem();
118
-						unset( $listItems[ $listItem->getId() ] );
118
+						unset($listItems[$listItem->getId()]);
119 119
 					}
120 120
 					else
121 121
 					{
@@ -123,35 +123,35 @@  discard block
 block discarded – undo
123 123
 						$refItem = $manager->createItem();
124 124
 					}
125 125
 
126
-					$list['media.typeid'] = $this->getTypeId( 'media/type', 'catalog', $type );
126
+					$list['media.typeid'] = $this->getTypeId('media/type', 'catalog', $type);
127 127
 					$list['media.domain'] = 'catalog';
128 128
 					$list['media.url'] = $url;
129 129
 
130
-					$refItem->fromArray( $this->addItemDefaults( $list ) );
131
-					$refItem = $manager->saveItem( $refItem );
130
+					$refItem->fromArray($this->addItemDefaults($list));
131
+					$refItem = $manager->saveItem($refItem);
132 132
 
133
-					$list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'media', $typecode );
133
+					$list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'media', $typecode);
134 134
 					$list['catalog.lists.parentid'] = $catalog->getId();
135 135
 					$list['catalog.lists.refid'] = $refItem->getId();
136 136
 					$list['catalog.lists.domain'] = 'media';
137 137
 
138
-					$listItem->fromArray( $this->addListItemDefaults( $list, $pos++ ) );
139
-					$listManager->saveItem( $listItem, false );
138
+					$listItem->fromArray($this->addListItemDefaults($list, $pos++));
139
+					$listManager->saveItem($listItem, false);
140 140
 				}
141 141
 			}
142 142
 
143
-			foreach( $listItems as $listItem ) {
143
+			foreach ($listItems as $listItem) {
144 144
 				$delete[] = $listItem->getRefId();
145 145
 			}
146 146
 
147
-			$manager->deleteItems( $delete );
148
-			$listManager->deleteItems( array_keys( $listItems ) );
147
+			$manager->deleteItems($delete);
148
+			$listManager->deleteItems(array_keys($listItems));
149 149
 
150
-			$data = $this->getObject()->process( $catalog, $data );
150
+			$data = $this->getObject()->process($catalog, $data);
151 151
 
152 152
 			$manager->commit();
153 153
 		}
154
-		catch( \Exception $e )
154
+		catch (\Exception $e)
155 155
 		{
156 156
 			$manager->rollback();
157 157
 			throw $e;
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 	 * @param array $list Associative list of domain item keys and their values, e.g. "media.status" => 1
168 168
 	 * @return array Given associative list enriched by default values if they were not already set
169 169
 	 */
170
-	protected function addItemDefaults( array $list )
170
+	protected function addItemDefaults(array $list)
171 171
 	{
172
-		if( !isset( $list['media.label'] ) ) {
172
+		if (!isset($list['media.label'])) {
173 173
 			$list['media.label'] = $list['media.url'];
174 174
 		}
175 175
 
176
-		if( !isset( $list['media.preview'] ) ) {
176
+		if (!isset($list['media.preview'])) {
177 177
 			$list['media.preview'] = $list['media.url'];
178 178
 		}
179 179
 
180
-		if( !isset( $list['media.status'] ) ) {
180
+		if (!isset($list['media.status'])) {
181 181
 			$list['media.status'] = 1;
182 182
 		}
183 183
 
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * @param array $list Associative list of key/value pairs from the mapping
192 192
 	 * @return boolean True if valid, false if not
193 193
 	 */
194
-	protected function checkEntry( array $list )
194
+	protected function checkEntry(array $list)
195 195
 	{
196
-		if( !isset( $list['media.url'] ) || $list['media.url'] === '' || isset( $list['catalog.lists.type'] )
197
-				&& $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes )
196
+		if (!isset($list['media.url']) || $list['media.url'] === '' || isset($list['catalog.lists.type'])
197
+				&& $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes)
198 198
 		) {
199 199
 			return false;
200 200
 		}
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/Text/Standard.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
43 43
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor
44 44
 	 */
45
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
-			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null )
45
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
46
+			\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
47 47
 	{
48
-		parent::__construct( $context, $mapping, $object );
48
+		parent::__construct($context, $mapping, $object);
49 49
 
50 50
 		/** controller/common/catalog/import/csv/processor/text/listtypes
51 51
 		 * Names of the catalog list types for texts that are updated or removed
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 * @see controller/common/catalog/import/csv/processor/price/listtypes
67 67
 		 * @see controller/common/catalog/import/csv/processor/catalog/listtypes
68 68
 		 */
69
-		$this->listTypes = $context->getConfig()->get( 'controller/common/catalog/import/csv/processor/text/listtypes' );
69
+		$this->listTypes = $context->getConfig()->get('controller/common/catalog/import/csv/processor/text/listtypes');
70 70
 	}
71 71
 
72 72
 
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
 	 * @param array $data List of CSV fields with position as key and data as value
78 78
 	 * @return array List of data which hasn't been imported
79 79
 	 */
80
-	public function process( \Aimeos\MShop\Catalog\Item\Iface $catalog, array $data )
80
+	public function process(\Aimeos\MShop\Catalog\Item\Iface $catalog, array $data)
81 81
 	{
82
-		$listManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
83
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'text' );
82
+		$listManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
83
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'text');
84 84
 		$manager->begin();
85 85
 
86 86
 		try
87 87
 		{
88 88
 			$delete = $listMap = [];
89
-			$map = $this->getMappedChunk( $data, $this->getMapping() );
90
-			$listItems = $catalog->getListItems( 'text', $this->listTypes );
89
+			$map = $this->getMappedChunk($data, $this->getMapping());
90
+			$listItems = $catalog->getListItems('text', $this->listTypes);
91 91
 
92
-			foreach( $listItems as $listItem )
92
+			foreach ($listItems as $listItem)
93 93
 			{
94
-				if( ( $refItem = $listItem->getRefItem() ) !== null ) {
95
-					$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
94
+				if (($refItem = $listItem->getRefItem()) !== null) {
95
+					$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
96 96
 				}
97 97
 			}
98 98
 
99
-			foreach( $map as $pos => $list )
99
+			foreach ($map as $pos => $list)
100 100
 			{
101
-				if( $this->checkEntry( $list ) === false ) {
101
+				if ($this->checkEntry($list) === false) {
102 102
 					continue;
103 103
 				}
104 104
 
105
-				$type = ( isset( $list['text.type'] ) ? $list['text.type'] : 'name' );
106
-				$typecode = ( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' );
105
+				$type = (isset($list['text.type']) ? $list['text.type'] : 'name');
106
+				$typecode = (isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default');
107 107
 
108
-				if( isset( $listMap[ $list['text.content'] ][$type][$typecode] ) )
108
+				if (isset($listMap[$list['text.content']][$type][$typecode]))
109 109
 				{
110
-					$listItem = $listMap[ $list['text.content'] ][$type][$typecode];
110
+					$listItem = $listMap[$list['text.content']][$type][$typecode];
111 111
 					$refItem = $listItem->getRefItem();
112
-					unset( $listItems[ $listItem->getId() ] );
112
+					unset($listItems[$listItem->getId()]);
113 113
 				}
114 114
 				else
115 115
 				{
@@ -117,33 +117,33 @@  discard block
 block discarded – undo
117 117
 					$refItem = $manager->createItem();
118 118
 				}
119 119
 
120
-				$list['text.typeid'] = $this->getTypeId( 'text/type', 'catalog', $type );
120
+				$list['text.typeid'] = $this->getTypeId('text/type', 'catalog', $type);
121 121
 				$list['text.domain'] = 'catalog';
122 122
 
123
-				$refItem->fromArray( $this->addItemDefaults( $list ) );
124
-				$refItem = $manager->saveItem( $refItem );
123
+				$refItem->fromArray($this->addItemDefaults($list));
124
+				$refItem = $manager->saveItem($refItem);
125 125
 
126
-				$list['catalog.lists.typeid'] = $this->getTypeId( 'catalog/lists/type', 'text', $typecode );
126
+				$list['catalog.lists.typeid'] = $this->getTypeId('catalog/lists/type', 'text', $typecode);
127 127
 				$list['catalog.lists.parentid'] = $catalog->getId();
128 128
 				$list['catalog.lists.refid'] = $refItem->getId();
129 129
 				$list['catalog.lists.domain'] = 'text';
130 130
 
131
-				$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
132
-				$listManager->saveItem( $listItem, false );
131
+				$listItem->fromArray($this->addListItemDefaults($list, $pos));
132
+				$listManager->saveItem($listItem, false);
133 133
 			}
134 134
 
135
-			foreach( $listItems as $listItem ) {
135
+			foreach ($listItems as $listItem) {
136 136
 				$delete[] = $listItem->getRefId();
137 137
 			}
138 138
 
139
-			$manager->deleteItems( $delete );
140
-			$listManager->deleteItems( array_keys( $listItems ) );
139
+			$manager->deleteItems($delete);
140
+			$listManager->deleteItems(array_keys($listItems));
141 141
 
142
-			$data = $this->getObject()->process( $catalog, $data );
142
+			$data = $this->getObject()->process($catalog, $data);
143 143
 
144 144
 			$manager->commit();
145 145
 		}
146
-		catch( \Exception $e )
146
+		catch (\Exception $e)
147 147
 		{
148 148
 			$manager->rollback();
149 149
 			throw $e;
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1
160 160
 	 * @return array Given associative list enriched by default values if they were not already set
161 161
 	 */
162
-	protected function addItemDefaults( array $list )
162
+	protected function addItemDefaults(array $list)
163 163
 	{
164
-		if( !isset( $list['text.label'] ) ) {
165
-			$list['text.label'] = mb_strcut( $list['text.content'], 0, 255 );
164
+		if (!isset($list['text.label'])) {
165
+			$list['text.label'] = mb_strcut($list['text.content'], 0, 255);
166 166
 		}
167 167
 
168
-		if( !isset( $list['text.languageid'] ) ) {
168
+		if (!isset($list['text.languageid'])) {
169 169
 			$list['text.languageid'] = $this->getContext()->getLocale()->getLanguageId();
170 170
 		}
171 171
 
172
-		if( !isset( $list['text.status'] ) ) {
172
+		if (!isset($list['text.status'])) {
173 173
 			$list['text.status'] = 1;
174 174
 		}
175 175
 
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
 	 * @param array $list Associative list of key/value pairs from the mapping
184 184
 	 * @return boolean True if valid, false if not
185 185
 	 */
186
-	protected function checkEntry( array $list )
186
+	protected function checkEntry(array $list)
187 187
 	{
188
-		if( !isset( $list['text.content'] ) || $list['text.content'] === '' || isset( $list['catalog.lists.type'] )
189
-			&& $this->listTypes !== null && !in_array( $list['catalog.lists.type'], (array) $this->listTypes )
188
+		if (!isset($list['text.content']) || $list['text.content'] === '' || isset($list['catalog.lists.type'])
189
+			&& $this->listTypes !== null && !in_array($list['catalog.lists.type'], (array) $this->listTypes)
190 190
 		) {
191 191
 			return false;
192 192
 		}
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.
common/src/Controller/Common/Catalog/Import/Csv/Processor/Base.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
33 33
 	 * @param \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object Decorated processor
34 34
 	 */
35
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping,
36
-		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null )
35
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping,
36
+		\Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface $object = null)
37 37
 	{
38 38
 		$this->context = $context;
39 39
 		$this->mapping = $mapping;
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 * @param integer $pos Computed position of the list item in the associated list of items
49 49
 	 * @return array Given associative list enriched by default values if they were not already set
50 50
 	 */
51
-	protected function addListItemDefaults( array $list, $pos )
51
+	protected function addListItemDefaults(array $list, $pos)
52 52
 	{
53
-		if( !isset( $list['catalog.lists.position'] ) ) {
53
+		if (!isset($list['catalog.lists.position'])) {
54 54
 			$list['catalog.lists.position'] = $pos;
55 55
 		}
56 56
 
57
-		if( !isset( $list['catalog.lists.status'] ) ) {
57
+		if (!isset($list['catalog.lists.status'])) {
58 58
 			$list['catalog.lists.status'] = 1;
59 59
 		}
60 60
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	protected function getObject()
94 94
 	{
95
-		if( $this->object === null ) {
96
-			throw new \Aimeos\Controller\Jobs\Exception( 'No processor object available' );
95
+		if ($this->object === null) {
96
+			throw new \Aimeos\Controller\Jobs\Exception('No processor object available');
97 97
 		}
98 98
 
99 99
 		return $this->object;
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param mixed $default Default value if key isn't found
109 109
 	 * @param mixed Value for the key in the list of the default value
110 110
 	 */
111
-	protected function getValue( array $list, $key, $default )
111
+	protected function getValue(array $list, $key, $default)
112 112
 	{
113
-		return ( isset( $list[$key] ) ? $list[$key] : $default );
113
+		return (isset($list[$key]) ? $list[$key] : $default);
114 114
 	}
115 115
 }
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/common/src/Controller/Common/Catalog/Import/Csv/Base.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	 * @param array $data Associative list of catalog codes and lists of CSV field indexes and their data
31 31
 	 * @return array Associative list of CSV field indexes and their converted data
32 32
 	 */
33
-	protected function convertData( array $convlist, array $data )
33
+	protected function convertData(array $convlist, array $data)
34 34
 	{
35
-		foreach( $convlist as $idx => $converter )
35
+		foreach ($convlist as $idx => $converter)
36 36
 		{
37
-			foreach( $data as $code => $list )
37
+			foreach ($data as $code => $list)
38 38
 			{
39
-				if( isset( $list[$idx] ) ) {
40
-					$data[$code][$idx] = $converter->translate( $list[$idx] );
39
+				if (isset($list[$idx])) {
40
+					$data[$code][$idx] = $converter->translate($list[$idx]);
41 41
 				}
42 42
 			}
43 43
 		}
@@ -53,38 +53,38 @@  discard block
 block discarded – undo
53 53
 	 * @param string|null Name of the cache implementation
54 54
 	 * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Cache\Iface Cache object
55 55
 	 */
56
-	protected function getCache( $type, $name = null )
56
+	protected function getCache($type, $name = null)
57 57
 	{
58 58
 		$context = $this->getContext();
59 59
 		$config = $context->getConfig();
60 60
 		$iface = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface';
61 61
 
62
-		if( ctype_alnum( $type ) === false )
62
+		if (ctype_alnum($type) === false)
63 63
 		{
64 64
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type : '<not a string>';
65
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
65
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
66 66
 		}
67 67
 
68
-		if( $name === null ) {
69
-			$name = $config->get( 'controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard' );
68
+		if ($name === null) {
69
+			$name = $config->get('controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard');
70 70
 		}
71 71
 
72
-		if( ctype_alnum( $name ) === false )
72
+		if (ctype_alnum($name) === false)
73 73
 		{
74 74
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type . '\\' . $name : '<not a string>';
75
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
75
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
76 76
 		}
77 77
 
78
-		$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name;
78
+		$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name;
79 79
 
80
-		if( class_exists( $classname ) === false ) {
81
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
80
+		if (class_exists($classname) === false) {
81
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
82 82
 		}
83 83
 
84
-		$object = new $classname( $context );
84
+		$object = new $classname($context);
85 85
 
86
-		if( !( $object instanceof $iface ) ) {
87
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) );
86
+		if (!($object instanceof $iface)) {
87
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface));
88 88
 		}
89 89
 
90 90
 		return $object;
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @param array $convmap List of converter names for the values at the position in the CSV file
98 98
 	 * @return array Associative list of positions and converter objects
99 99
 	 */
100
-	protected function getConverterList( array $convmap )
100
+	protected function getConverterList(array $convmap)
101 101
 	{
102 102
 		$convlist = [];
103 103
 
104
-		foreach( $convmap as $idx => $name ) {
105
-			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name );
104
+		foreach ($convmap as $idx => $name) {
105
+			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name);
106 106
 		}
107 107
 
108 108
 		return $convlist;
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
 	 * @param integer $codePos Column position which contains the unique catalog code (starting from 0)
118 118
 	 * @return array List of arrays with catalog codes as keys and list of values from the CSV file
119 119
 	 */
120
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
120
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
121 121
 	{
122 122
 		$count = 0;
123 123
 		$data = [];
124 124
 
125
-		while( $content->valid() && $count++ < $maxcnt )
125
+		while ($content->valid() && $count++ < $maxcnt)
126 126
 		{
127 127
 			$row = $content->current();
128
-			$data[ $row[$codePos] ] = $row;
128
+			$data[$row[$codePos]] = $row;
129 129
 			$content->next();
130 130
 		}
131 131
 
@@ -181,21 +181,21 @@  discard block
 block discarded – undo
181 181
 	 * @param array $mapping List of domain item keys with the CSV field position as key
182 182
 	 * @return array List of associative arrays containing the chunked properties
183 183
 	 */
184
-	protected function getMappedChunk( array &$data, array $mapping )
184
+	protected function getMappedChunk(array &$data, array $mapping)
185 185
 	{
186 186
 		$idx = 0;
187 187
 		$map = [];
188 188
 
189
-		foreach( $mapping as $pos => $key )
189
+		foreach ($mapping as $pos => $key)
190 190
 		{
191
-			if( isset( $map[$idx][$key] ) ) {
191
+			if (isset($map[$idx][$key])) {
192 192
 				$idx++;
193 193
 			}
194 194
 
195
-			if( isset( $data[$pos] ) )
195
+			if (isset($data[$pos]))
196 196
 			{
197 197
 				$map[$idx][$key] = $data[$pos];
198
-				unset( $data[$pos] );
198
+				unset($data[$pos]);
199 199
 			}
200 200
 		}
201 201
 
@@ -209,39 +209,39 @@  discard block
 block discarded – undo
209 209
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
210 210
 	 * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface Processor object
211 211
 	 */
212
-	protected function getProcessors( array $mappings )
212
+	protected function getProcessors(array $mappings)
213 213
 	{
214 214
 		$context = $this->getContext();
215 215
 		$config = $context->getConfig();
216 216
 		$iface = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface';
217
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done( $context, [] );
217
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done($context, []);
218 218
 
219
-		foreach( $mappings as $type => $mapping )
219
+		foreach ($mappings as $type => $mapping)
220 220
 		{
221
-			if( ctype_alnum( $type ) === false )
221
+			if (ctype_alnum($type) === false)
222 222
 			{
223 223
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type : '<not a string>';
224
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
224
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
225 225
 			}
226 226
 
227
-			$name = $config->get( 'controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard' );
227
+			$name = $config->get('controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard');
228 228
 
229
-			if( ctype_alnum( $name ) === false )
229
+			if (ctype_alnum($name) === false)
230 230
 			{
231 231
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
232
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
232
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
233 233
 			}
234 234
 
235
-			$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
235
+			$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
236 236
 
237
-			if( class_exists( $classname ) === false ) {
238
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
237
+			if (class_exists($classname) === false) {
238
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
239 239
 			}
240 240
 
241
-			$object = new $classname( $context, $mapping, $object );
241
+			$object = new $classname($context, $mapping, $object);
242 242
 
243
-			if( !( $object instanceof $iface ) ) {
244
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) );
243
+			if (!($object instanceof $iface)) {
244
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface));
245 245
 			}
246 246
 		}
247 247
 
@@ -257,23 +257,23 @@  discard block
 block discarded – undo
257 257
 	 * @param string $code Unique code of the type item
258 258
 	 * @return string Unique ID of the type item
259 259
 	 */
260
-	protected function getTypeId( $path, $domain, $code )
260
+	protected function getTypeId($path, $domain, $code)
261 261
 	{
262
-		if( !isset( self::$types[$path][$domain] ) )
262
+		if (!isset(self::$types[$path][$domain]))
263 263
 		{
264
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path );
265
-			$key = str_replace( '/', '.', $path );
264
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path);
265
+			$key = str_replace('/', '.', $path);
266 266
 
267 267
 			$search = $manager->createSearch();
268
-			$search->setConditions( $search->compare( '==', $key . '.domain', $domain ) );
268
+			$search->setConditions($search->compare('==', $key . '.domain', $domain));
269 269
 
270
-			foreach( $manager->searchItems( $search ) as $id => $item ) {
271
-				self::$types[$path][$domain][ $item->getCode() ] = $id;
270
+			foreach ($manager->searchItems($search) as $id => $item) {
271
+				self::$types[$path][$domain][$item->getCode()] = $id;
272 272
 			}
273 273
 		}
274 274
 
275
-		if( !isset( self::$types[$path][$domain][$code] ) ) {
276
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) );
275
+		if (!isset(self::$types[$path][$domain][$code])) {
276
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path));
277 277
 		}
278 278
 
279 279
 		return self::$types[$path][$domain][$code];
Please login to merge, or discard this patch.