Completed
Push — master ( b85694...d1869e )
by Aimeos
02:13
created
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/Product/Import/Csv/Base.php 1 patch
Spacing   +56 added lines, -56 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 product 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,36 +53,36 @@  discard block
 block discarded – undo
53 53
 	 * @param string|null Name of the cache implementation
54 54
 	 * @return \Aimeos\Controller\Common\Product\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
 
61
-		if( ctype_alnum( $type ) === false )
61
+		if (ctype_alnum($type) === false)
62 62
 		{
63 63
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>';
64
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
64
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
65 65
 		}
66 66
 
67
-		if( $name === null ) {
68
-			$name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' );
67
+		if ($name === null) {
68
+			$name = $config->get('controller/common/product/import/csv/cache/' . $type . '/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\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $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
-		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name;
77
+		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name;
78 78
 
79
-		if( class_exists( $classname ) === false ) {
80
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
79
+		if (class_exists($classname) === false) {
80
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
81 81
 		}
82 82
 
83
-		$object = new $classname( $context );
83
+		$object = new $classname($context);
84 84
 
85
-		\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object );
85
+		\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object);
86 86
 
87 87
 		return $object;
88 88
 	}
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	 * @param array $convmap List of converter names for the values at the position in the CSV file
95 95
 	 * @return array Associative list of positions and converter objects
96 96
 	 */
97
-	protected function getConverterList( array $convmap )
97
+	protected function getConverterList(array $convmap)
98 98
 	{
99 99
 		$convlist = [];
100 100
 
101
-		foreach( $convmap as $idx => $name ) {
102
-			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name );
101
+		foreach ($convmap as $idx => $name) {
102
+			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name);
103 103
 		}
104 104
 
105 105
 		return $convlist;
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 	 * @param integer $codePos Column position which contains the unique product code (starting from 0)
115 115
 	 * @return array List of arrays with product codes as keys and list of values from the CSV file
116 116
 	 */
117
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
117
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
118 118
 	{
119 119
 		$count = 0;
120 120
 		$data = [];
121 121
 
122
-		while( $content->valid() && $count++ < $maxcnt )
122
+		while ($content->valid() && $count++ < $maxcnt)
123 123
 		{
124 124
 			$row = $content->current();
125
-			$data[ $row[$codePos] ] = $row;
125
+			$data[$row[$codePos]] = $row;
126 126
 			$content->next();
127 127
 		}
128 128
 
@@ -221,21 +221,21 @@  discard block
 block discarded – undo
221 221
 	 * @param array $mapping List of domain item keys with the CSV field position as key
222 222
 	 * @return array List of associative arrays containing the chunked properties
223 223
 	 */
224
-	protected function getMappedChunk( array &$data, array $mapping )
224
+	protected function getMappedChunk(array &$data, array $mapping)
225 225
 	{
226 226
 		$idx = 0;
227 227
 		$map = [];
228 228
 
229
-		foreach( $mapping as $pos => $key )
229
+		foreach ($mapping as $pos => $key)
230 230
 		{
231
-			if( isset( $map[$idx][$key] ) ) {
231
+			if (isset($map[$idx][$key])) {
232 232
 				$idx++;
233 233
 			}
234 234
 
235
-			if( isset( $data[$pos] ) )
235
+			if (isset($data[$pos]))
236 236
 			{
237 237
 				$map[$idx][$key] = $data[$pos];
238
-				unset( $data[$pos] );
238
+				unset($data[$pos]);
239 239
 			}
240 240
 		}
241 241
 
@@ -249,37 +249,37 @@  discard block
 block discarded – undo
249 249
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
250 250
 	 * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object
251 251
 	 */
252
-	protected function getProcessors( array $mappings )
252
+	protected function getProcessors(array $mappings)
253 253
 	{
254 254
 		$context = $this->getContext();
255 255
 		$config = $context->getConfig();
256
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, [] );
256
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, []);
257 257
 
258
-		foreach( $mappings as $type => $mapping )
258
+		foreach ($mappings as $type => $mapping)
259 259
 		{
260
-			if( ctype_alnum( $type ) === false )
260
+			if (ctype_alnum($type) === false)
261 261
 			{
262 262
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type : '<not a string>';
263
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
263
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
264 264
 			}
265 265
 
266
-			$name = $config->get( 'controller/common/product/import/csv/processor/' . $type . '/name', 'Standard' );
266
+			$name = $config->get('controller/common/product/import/csv/processor/' . $type . '/name', 'Standard');
267 267
 
268
-			if( ctype_alnum( $name ) === false )
268
+			if (ctype_alnum($name) === false)
269 269
 			{
270 270
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
271
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
271
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
272 272
 			}
273 273
 
274
-			$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
274
+			$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
275 275
 
276
-			if( class_exists( $classname ) === false ) {
277
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
276
+			if (class_exists($classname) === false) {
277
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
278 278
 			}
279 279
 
280
-			$object = new $classname( $context, $mapping, $object );
280
+			$object = new $classname($context, $mapping, $object);
281 281
 
282
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object );
282
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object);
283 283
 		}
284 284
 
285 285
 		return $object;
@@ -293,17 +293,17 @@  discard block
 block discarded – undo
293 293
 	 * @param array $domains List of domains whose items should be fetched too
294 294
 	 * @return array Associative list of product codes as key and product items as value
295 295
 	 */
296
-	protected function getProducts( array $codes, array $domains )
296
+	protected function getProducts(array $codes, array $domains)
297 297
 	{
298 298
 		$result = [];
299
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
299
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
300 300
 
301 301
 		$search = $manager->createSearch();
302
-		$search->setConditions( $search->compare( '==', 'product.code', $codes ) );
303
-		$search->setSlice( 0, count( $codes ) );
302
+		$search->setConditions($search->compare('==', 'product.code', $codes));
303
+		$search->setSlice(0, count($codes));
304 304
 
305
-		foreach( $manager->searchItems( $search, $domains ) as $item ) {
306
-			$result[ $item->getCode() ] = $item;
305
+		foreach ($manager->searchItems($search, $domains) as $item) {
306
+			$result[$item->getCode()] = $item;
307 307
 		}
308 308
 
309 309
 		return $result;
@@ -318,23 +318,23 @@  discard block
 block discarded – undo
318 318
 	 * @param string $code Unique code of the type item
319 319
 	 * @return string Unique ID of the type item
320 320
 	 */
321
-	protected function getTypeId( $path, $domain, $code )
321
+	protected function getTypeId($path, $domain, $code)
322 322
 	{
323
-		if( !isset( self::$types[$path][$domain] ) )
323
+		if (!isset(self::$types[$path][$domain]))
324 324
 		{
325
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path );
326
-			$key = str_replace( '/', '.', $path );
325
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path);
326
+			$key = str_replace('/', '.', $path);
327 327
 
328 328
 			$search = $manager->createSearch();
329
-			$search->setConditions( $search->compare( '==', $key . '.domain', $domain ) );
329
+			$search->setConditions($search->compare('==', $key . '.domain', $domain));
330 330
 
331
-			foreach( $manager->searchItems( $search ) as $id => $item ) {
332
-				self::$types[$path][$domain][ $item->getCode() ] = $id;
331
+			foreach ($manager->searchItems($search) as $id => $item) {
332
+				self::$types[$path][$domain][$item->getCode()] = $id;
333 333
 			}
334 334
 		}
335 335
 
336
-		if( !isset( self::$types[$path][$domain][$code] ) ) {
337
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) );
336
+		if (!isset(self::$types[$path][$domain][$code])) {
337
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path));
338 338
 		}
339 339
 
340 340
 		return self::$types[$path][$domain][$code];
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/common/src/Controller/Common/Catalog/Import/Csv/Base.php 1 patch
Spacing   +50 added lines, -50 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,36 +53,36 @@  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
 
61
-		if( ctype_alnum( $type ) === false )
61
+		if (ctype_alnum($type) === false)
62 62
 		{
63 63
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type : '<not a string>';
64
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
64
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
65 65
 		}
66 66
 
67
-		if( $name === null ) {
68
-			$name = $config->get( 'controller/common/catalog/import/csv/cache/' . $type . '/name', 'Standard' );
67
+		if ($name === null) {
68
+			$name = $config->get('controller/common/catalog/import/csv/cache/' . $type . '/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\\Common\\Catalog\\Import\\Csv\\Cache\\' . $type . '\\' . $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
-		$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name;
77
+		$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name;
78 78
 
79
-		if( class_exists( $classname ) === false ) {
80
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
79
+		if (class_exists($classname) === false) {
80
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
81 81
 		}
82 82
 
83
-		$object = new $classname( $context );
83
+		$object = new $classname($context);
84 84
 
85
-		\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface', $object );
85
+		\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Cache\\Iface', $object);
86 86
 
87 87
 		return $object;
88 88
 	}
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	 * @param array $convmap List of converter names for the values at the position in the CSV file
95 95
 	 * @return array Associative list of positions and converter objects
96 96
 	 */
97
-	protected function getConverterList( array $convmap )
97
+	protected function getConverterList(array $convmap)
98 98
 	{
99 99
 		$convlist = [];
100 100
 
101
-		foreach( $convmap as $idx => $name ) {
102
-			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name );
101
+		foreach ($convmap as $idx => $name) {
102
+			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name);
103 103
 		}
104 104
 
105 105
 		return $convlist;
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 	 * @param integer $codePos Column position which contains the unique catalog code (starting from 0)
115 115
 	 * @return array List of arrays with catalog codes as keys and list of values from the CSV file
116 116
 	 */
117
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
117
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
118 118
 	{
119 119
 		$count = 0;
120 120
 		$data = [];
121 121
 
122
-		while( $content->valid() && $count++ < $maxcnt )
122
+		while ($content->valid() && $count++ < $maxcnt)
123 123
 		{
124 124
 			$row = $content->current();
125
-			$data[ $row[$codePos] ] = $row;
125
+			$data[$row[$codePos]] = $row;
126 126
 			$content->next();
127 127
 		}
128 128
 
@@ -178,21 +178,21 @@  discard block
 block discarded – undo
178 178
 	 * @param array $mapping List of domain item keys with the CSV field position as key
179 179
 	 * @return array List of associative arrays containing the chunked properties
180 180
 	 */
181
-	protected function getMappedChunk( array &$data, array $mapping )
181
+	protected function getMappedChunk(array &$data, array $mapping)
182 182
 	{
183 183
 		$idx = 0;
184 184
 		$map = [];
185 185
 
186
-		foreach( $mapping as $pos => $key )
186
+		foreach ($mapping as $pos => $key)
187 187
 		{
188
-			if( isset( $map[$idx][$key] ) ) {
188
+			if (isset($map[$idx][$key])) {
189 189
 				$idx++;
190 190
 			}
191 191
 
192
-			if( isset( $data[$pos] ) )
192
+			if (isset($data[$pos]))
193 193
 			{
194 194
 				$map[$idx][$key] = $data[$pos];
195
-				unset( $data[$pos] );
195
+				unset($data[$pos]);
196 196
 			}
197 197
 		}
198 198
 
@@ -206,37 +206,37 @@  discard block
 block discarded – undo
206 206
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
207 207
 	 * @return \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Iface Processor object
208 208
 	 */
209
-	protected function getProcessors( array $mappings )
209
+	protected function getProcessors(array $mappings)
210 210
 	{
211 211
 		$context = $this->getContext();
212 212
 		$config = $context->getConfig();
213
-		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done( $context, [] );
213
+		$object = new \Aimeos\Controller\Common\Catalog\Import\Csv\Processor\Done($context, []);
214 214
 
215
-		foreach( $mappings as $type => $mapping )
215
+		foreach ($mappings as $type => $mapping)
216 216
 		{
217
-			if( ctype_alnum( $type ) === false )
217
+			if (ctype_alnum($type) === false)
218 218
 			{
219 219
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type : '<not a string>';
220
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
220
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
221 221
 			}
222 222
 
223
-			$name = $config->get( 'controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard' );
223
+			$name = $config->get('controller/common/catalog/import/csv/processor/' . $type . '/name', 'Standard');
224 224
 
225
-			if( ctype_alnum( $name ) === false )
225
+			if (ctype_alnum($name) === false)
226 226
 			{
227 227
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
228
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
228
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
229 229
 			}
230 230
 
231
-			$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
231
+			$classname = '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
232 232
 
233
-			if( class_exists( $classname ) === false ) {
234
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
233
+			if (class_exists($classname) === false) {
234
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
235 235
 			}
236 236
 
237
-			$object = new $classname( $context, $mapping, $object );
237
+			$object = new $classname($context, $mapping, $object);
238 238
 
239
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $object );
239
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Catalog\\Import\\Csv\\Processor\\Iface', $object);
240 240
 		}
241 241
 
242 242
 		return $object;
@@ -251,23 +251,23 @@  discard block
 block discarded – undo
251 251
 	 * @param string $code Unique code of the type item
252 252
 	 * @return string Unique ID of the type item
253 253
 	 */
254
-	protected function getTypeId( $path, $domain, $code )
254
+	protected function getTypeId($path, $domain, $code)
255 255
 	{
256
-		if( !isset( self::$types[$path][$domain] ) )
256
+		if (!isset(self::$types[$path][$domain]))
257 257
 		{
258
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path );
259
-			$key = str_replace( '/', '.', $path );
258
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path);
259
+			$key = str_replace('/', '.', $path);
260 260
 
261 261
 			$search = $manager->createSearch();
262
-			$search->setConditions( $search->compare( '==', $key . '.domain', $domain ) );
262
+			$search->setConditions($search->compare('==', $key . '.domain', $domain));
263 263
 
264
-			foreach( $manager->searchItems( $search ) as $id => $item ) {
265
-				self::$types[$path][$domain][ $item->getCode() ] = $id;
264
+			foreach ($manager->searchItems($search) as $id => $item) {
265
+				self::$types[$path][$domain][$item->getCode()] = $id;
266 266
 			}
267 267
 		}
268 268
 
269
-		if( !isset( self::$types[$path][$domain][$code] ) ) {
270
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) );
269
+		if (!isset(self::$types[$path][$domain][$code])) {
270
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path));
271 271
 		}
272 272
 
273 273
 		return self::$types[$path][$domain][$code];
Please login to merge, or discard this patch.
controller/common/src/Controller/Common/Product/Import/Csv/Traits.php 1 patch
Spacing   +56 added lines, -56 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 product 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,36 +53,36 @@  discard block
 block discarded – undo
53 53
 	 * @param string|null Name of the cache implementation
54 54
 	 * @return \Aimeos\Controller\Common\Product\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
 
61
-		if( ctype_alnum( $type ) === false )
61
+		if (ctype_alnum($type) === false)
62 62
 		{
63 63
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . $type : '<not a string>';
64
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
64
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
65 65
 		}
66 66
 
67
-		if( $name === null ) {
68
-			$name = $config->get( 'controller/common/product/import/csv/cache/' . $type . '/name', 'Standard' );
67
+		if ($name === null) {
68
+			$name = $config->get('controller/common/product/import/csv/cache/' . $type . '/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\\Common\\Product\\Import\\Csv\\Cache\\' . $type . '\\' . $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
-		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst( $type ) . '\\' . $name;
77
+		$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\' . ucfirst($type) . '\\' . $name;
78 78
 
79
-		if( class_exists( $classname ) === false ) {
80
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
79
+		if (class_exists($classname) === false) {
80
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
81 81
 		}
82 82
 
83
-		$object = new $classname( $context );
83
+		$object = new $classname($context);
84 84
 
85
-		\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object );
85
+		\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Cache\\Iface', $object);
86 86
 
87 87
 		return $object;
88 88
 	}
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	 * @param array $convmap List of converter names for the values at the position in the CSV file
95 95
 	 * @return array Associative list of positions and converter objects
96 96
 	 */
97
-	protected function getConverterList( array $convmap )
97
+	protected function getConverterList(array $convmap)
98 98
 	{
99 99
 		$convlist = [];
100 100
 
101
-		foreach( $convmap as $idx => $name ) {
102
-			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter( $name );
101
+		foreach ($convmap as $idx => $name) {
102
+			$convlist[$idx] = \Aimeos\MW\Convert\Factory::createConverter($name);
103 103
 		}
104 104
 
105 105
 		return $convlist;
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 	 * @param integer $codePos Column position which contains the unique product code (starting from 0)
115 115
 	 * @return array List of arrays with product codes as keys and list of values from the CSV file
116 116
 	 */
117
-	protected function getData( \Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos )
117
+	protected function getData(\Aimeos\MW\Container\Content\Iface $content, $maxcnt, $codePos)
118 118
 	{
119 119
 		$count = 0;
120 120
 		$data = [];
121 121
 
122
-		while( $content->valid() && $count++ < $maxcnt )
122
+		while ($content->valid() && $count++ < $maxcnt)
123 123
 		{
124 124
 			$row = $content->current();
125
-			$data[ $row[$codePos] ] = $row;
125
+			$data[$row[$codePos]] = $row;
126 126
 			$content->next();
127 127
 		}
128 128
 
@@ -221,21 +221,21 @@  discard block
 block discarded – undo
221 221
 	 * @param array $mapping List of domain item keys with the CSV field position as key
222 222
 	 * @return array List of associative arrays containing the chunked properties
223 223
 	 */
224
-	protected function getMappedChunk( array &$data, array $mapping )
224
+	protected function getMappedChunk(array &$data, array $mapping)
225 225
 	{
226 226
 		$idx = 0;
227 227
 		$map = [];
228 228
 
229
-		foreach( $mapping as $pos => $key )
229
+		foreach ($mapping as $pos => $key)
230 230
 		{
231
-			if( isset( $map[$idx][$key] ) ) {
231
+			if (isset($map[$idx][$key])) {
232 232
 				$idx++;
233 233
 			}
234 234
 
235
-			if( isset( $data[$pos] ) )
235
+			if (isset($data[$pos]))
236 236
 			{
237 237
 				$map[$idx][$key] = $data[$pos];
238
-				unset( $data[$pos] );
238
+				unset($data[$pos]);
239 239
 			}
240 240
 		}
241 241
 
@@ -249,37 +249,37 @@  discard block
 block discarded – undo
249 249
 	 * @param array $mappings Associative list of processor types as keys and index/data mappings as values
250 250
 	 * @return \Aimeos\Controller\Common\Product\Import\Csv\Processor\Iface Processor object
251 251
 	 */
252
-	protected function getProcessors( array $mappings )
252
+	protected function getProcessors(array $mappings)
253 253
 	{
254 254
 		$context = $this->getContext();
255 255
 		$config = $context->getConfig();
256
-		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done( $context, [] );
256
+		$object = new \Aimeos\Controller\Common\Product\Import\Csv\Processor\Done($context, []);
257 257
 
258
-		foreach( $mappings as $type => $mapping )
258
+		foreach ($mappings as $type => $mapping)
259 259
 		{
260
-			if( ctype_alnum( $type ) === false )
260
+			if (ctype_alnum($type) === false)
261 261
 			{
262 262
 				$classname = is_string($type) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type : '<not a string>';
263
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
263
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
264 264
 			}
265 265
 
266
-			$name = $config->get( 'controller/common/product/import/csv/processor/' . $type . '/name', 'Standard' );
266
+			$name = $config->get('controller/common/product/import/csv/processor/' . $type . '/name', 'Standard');
267 267
 
268
-			if( ctype_alnum( $name ) === false )
268
+			if (ctype_alnum($name) === false)
269 269
 			{
270 270
 				$classname = is_string($name) ? '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . $type . '\\' . $name : '<not a string>';
271
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
271
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
272 272
 			}
273 273
 
274
-			$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst( $type ) . '\\' . $name;
274
+			$classname = '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\' . ucfirst($type) . '\\' . $name;
275 275
 
276
-			if( class_exists( $classname ) === false ) {
277
-				throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Class "%1$s" not found', $classname ) );
276
+			if (class_exists($classname) === false) {
277
+				throw new \Aimeos\Controller\Jobs\Exception(sprintf('Class "%1$s" not found', $classname));
278 278
 			}
279 279
 
280
-			$object = new $classname( $context, $mapping, $object );
280
+			$object = new $classname($context, $mapping, $object);
281 281
 
282
-			\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object );
282
+			\Aimeos\MW\Common\Base::checkClass('\\Aimeos\\Controller\\Common\\Product\\Import\\Csv\\Processor\\Iface', $object);
283 283
 		}
284 284
 
285 285
 		return $object;
@@ -293,17 +293,17 @@  discard block
 block discarded – undo
293 293
 	 * @param array $domains List of domains whose items should be fetched too
294 294
 	 * @return array Associative list of product codes as key and product items as value
295 295
 	 */
296
-	protected function getProducts( array $codes, array $domains )
296
+	protected function getProducts(array $codes, array $domains)
297 297
 	{
298 298
 		$result = [];
299
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
299
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
300 300
 
301 301
 		$search = $manager->createSearch();
302
-		$search->setConditions( $search->compare( '==', 'product.code', $codes ) );
303
-		$search->setSlice( 0, count( $codes ) );
302
+		$search->setConditions($search->compare('==', 'product.code', $codes));
303
+		$search->setSlice(0, count($codes));
304 304
 
305
-		foreach( $manager->searchItems( $search, $domains ) as $item ) {
306
-			$result[ $item->getCode() ] = $item;
305
+		foreach ($manager->searchItems($search, $domains) as $item) {
306
+			$result[$item->getCode()] = $item;
307 307
 		}
308 308
 
309 309
 		return $result;
@@ -318,23 +318,23 @@  discard block
 block discarded – undo
318 318
 	 * @param string $code Unique code of the type item
319 319
 	 * @return string Unique ID of the type item
320 320
 	 */
321
-	protected function getTypeId( $path, $domain, $code )
321
+	protected function getTypeId($path, $domain, $code)
322 322
 	{
323
-		if( !isset( self::$types[$path][$domain] ) )
323
+		if (!isset(self::$types[$path][$domain]))
324 324
 		{
325
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $path );
326
-			$key = str_replace( '/', '.', $path );
325
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $path);
326
+			$key = str_replace('/', '.', $path);
327 327
 
328 328
 			$search = $manager->createSearch();
329
-			$search->setConditions( $search->compare( '==', $key . '.domain', $domain ) );
329
+			$search->setConditions($search->compare('==', $key . '.domain', $domain));
330 330
 
331
-			foreach( $manager->searchItems( $search ) as $id => $item ) {
332
-				self::$types[$path][$domain][ $item->getCode() ] = $id;
331
+			foreach ($manager->searchItems($search) as $id => $item) {
332
+				self::$types[$path][$domain][$item->getCode()] = $id;
333 333
 			}
334 334
 		}
335 335
 
336
-		if( !isset( self::$types[$path][$domain][$code] ) ) {
337
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path ) );
336
+		if (!isset(self::$types[$path][$domain][$code])) {
337
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('No type item for "%1$s/%2$s" in "%3$s" found', $domain, $code, $path));
338 338
 		}
339 339
 
340 340
 		return self::$types[$path][$domain][$code];
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/End/Standard.php 2 patches
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.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@
 block discarded – undo
98 98
 					}
99 99
 
100 100
 					$manager->saveItem( $item->setReason( $reason )->setStatus( 0 ) );
101
-				}
102
-				catch( \Exception $e )
101
+				} catch( \Exception $e )
103 102
 				{
104 103
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
105 104
 					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Renew/Standard.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -93,8 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 						$interval = new \DateInterval( $item->getInterval() );
95 95
 						$item->setDateNext( date_create()->add( $interval )->format( 'Y-m-d' ) );
96
-					}
97
-					catch( \Exception $e )
96
+					} catch( \Exception $e )
98 97
 					{
99 98
 						$item->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT );
100 99
 						$item->setDateEnd( date_create()->format( 'Y-m-d' ) );
@@ -108,8 +107,7 @@  discard block
 block discarded – undo
108 107
 					foreach( $processors as $processor ) {
109 108
 						$processor->renew( $item, $newInvoice );
110 109
 					}
111
-				}
112
-				catch( \Exception $e )
110
+				} catch( \Exception $e )
113 111
 				{
114 112
 					$msg = 'Unable to process subscription with ID "%1$s": %2$s';
115 113
 					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
@@ -152,8 +150,7 @@  discard block
 block discarded – undo
152 150
 
153 151
 			$context->setUserId( $baseItem->getCustomerId() );
154 152
 			$context->setGroupIds( $customerItem->getGroups() );
155
-		}
156
-		catch( \Exception $e ) {} // Subscription without account
153
+		} catch( \Exception $e ) {} // Subscription without account
157 154
 
158 155
 		return $context;
159 156
 	}
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 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 renew' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process renew');
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', 'Renews subscriptions at next date' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Renews subscriptions at next date');
43 43
 	}
44 44
 
45 45
 
@@ -54,73 +54,73 @@  discard block
 block discarded – undo
54 54
 		$config = $context->getConfig();
55 55
 		$logger = $context->getLogger();
56 56
 
57
-		$names = (array) $config->get( 'controller/common/subscription/process/processors', [] );
57
+		$names = (array) $config->get('controller/common/subscription/process/processors', []);
58 58
 
59
-		$date = date( 'Y-m-d' );
60
-		$processors = $this->getProcessors( $names );
61
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
59
+		$date = date('Y-m-d');
60
+		$processors = $this->getProcessors($names);
61
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
62 62
 
63
-		$search = $manager->createSearch( true );
63
+		$search = $manager->createSearch(true);
64 64
 		$expr = [
65
-			$search->compare( '<=', 'subscription.datenext', $date ),
66
-			$search->combine( '||', [
67
-				$search->compare( '==', 'subscription.dateend', null ),
68
-				$search->compare( '>', 'subscription.dateend', $date ),
69
-			] ),
65
+			$search->compare('<=', 'subscription.datenext', $date),
66
+			$search->combine('||', [
67
+				$search->compare('==', 'subscription.dateend', null),
68
+				$search->compare('>', 'subscription.dateend', $date),
69
+			]),
70 70
 			$search->getConditions(),
71 71
 		];
72
-		$search->setConditions( $search->combine( '&&', $expr ) );
73
-		$search->setSortations( [$search->sort( '+', 'subscription.id' )] );
72
+		$search->setConditions($search->combine('&&', $expr));
73
+		$search->setSortations([$search->sort('+', 'subscription.id')]);
74 74
 
75 75
 		$start = 0;
76 76
 
77 77
 		do
78 78
 		{
79
-			$search->setSlice( $start, 100 );
80
-			$items = $manager->searchItems( $search );
79
+			$search->setSlice($start, 100);
80
+			$items = $manager->searchItems($search);
81 81
 
82
-			foreach( $items as $item )
82
+			foreach ($items as $item)
83 83
 			{
84 84
 				try
85 85
 				{
86
-					$context = $this->createContext( $item->getOrderBaseId() );
87
-					$newOrder = $this->createOrderBase( $context, $item );
88
-					$newInvoice = $this->createOrderInvoice( $context, $newOrder );
86
+					$context = $this->createContext($item->getOrderBaseId());
87
+					$newOrder = $this->createOrderBase($context, $item);
88
+					$newInvoice = $this->createOrderInvoice($context, $newOrder);
89 89
 
90 90
 					try
91 91
 					{
92
-						$this->createPayment( $context, $newOrder, $newInvoice );
92
+						$this->createPayment($context, $newOrder, $newInvoice);
93 93
 
94
-						$interval = new \DateInterval( $item->getInterval() );
95
-						$item->setDateNext( date_create()->add( $interval )->format( 'Y-m-d' ) );
94
+						$interval = new \DateInterval($item->getInterval());
95
+						$item->setDateNext(date_create()->add($interval)->format('Y-m-d'));
96 96
 					}
97
-					catch( \Exception $e )
97
+					catch (\Exception $e)
98 98
 					{
99
-						$item->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT );
100
-						$item->setDateEnd( date_create()->format( 'Y-m-d' ) );
101
-						$manager->saveItem( $item );
99
+						$item->setReason(\Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT);
100
+						$item->setDateEnd(date_create()->format('Y-m-d'));
101
+						$manager->saveItem($item);
102 102
 
103 103
 						throw $e;
104 104
 					}
105 105
 
106
-					$manager->saveItem( $item );
106
+					$manager->saveItem($item);
107 107
 
108
-					foreach( $processors as $processor ) {
109
-						$processor->renew( $item, $newInvoice );
108
+					foreach ($processors as $processor) {
109
+						$processor->renew($item, $newInvoice);
110 110
 					}
111 111
 				}
112
-				catch( \Exception $e )
112
+				catch (\Exception $e)
113 113
 				{
114 114
 					$msg = 'Unable to process subscription with ID "%1$s": %2$s';
115
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
116
-					$logger->log( $e->getTraceAsString() );
115
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
116
+					$logger->log($e->getTraceAsString());
117 117
 				}
118 118
 			}
119 119
 
120
-			$count = count( $items );
120
+			$count = count($items);
121 121
 			$start += $count;
122 122
 		}
123
-		while( $count === $search->getSliceSize() );
123
+		while ($count === $search->getSliceSize());
124 124
 	}
125 125
 
126 126
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param array $codes List of coupon codes that should be added to the given basket
133 133
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Basket, maybe with coupons added
134 134
 	 */
135
-	protected function addBasketCoupons( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes )
135
+	protected function addBasketCoupons(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket, array $codes)
136 136
 	{
137 137
 		/** controller/jobs/subcription/process/renew/standard/use-coupons
138 138
 		 *
@@ -146,34 +146,34 @@  discard block
 block discarded – undo
146 146
 		 * @category User
147 147
 		 * @since 2018.10
148 148
 		 */
149
-		if( $context->getConfig()->get( 'controller/jobs/subcription/process/renew/standard/use-coupons', false ) )
149
+		if ($context->getConfig()->get('controller/jobs/subcription/process/renew/standard/use-coupons', false))
150 150
 		{
151
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' );
152
-			$codeManager = \Aimeos\MShop\Factory::createManager( $context, 'coupon/code' );
151
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'coupon');
152
+			$codeManager = \Aimeos\MShop\Factory::createManager($context, 'coupon/code');
153 153
 
154
-			foreach( $codes as $code )
154
+			foreach ($codes as $code)
155 155
 			{
156
-				$search = $manager->createSearch( true )->setSlice( 0, 1 );
156
+				$search = $manager->createSearch(true)->setSlice(0, 1);
157 157
 				$expr = [
158
-					$search->compare( '==', 'coupon.code.code', $code ),
159
-					$codeManager->createSearch( true )->getConditions(),
158
+					$search->compare('==', 'coupon.code.code', $code),
159
+					$codeManager->createSearch(true)->getConditions(),
160 160
 					$search->getConditions(),
161 161
 				];
162
-				$search->setConditions( $search->combine( '&&', $expr ) );
162
+				$search->setConditions($search->combine('&&', $expr));
163 163
 
164
-				$result = $manager->searchItems( $search );
164
+				$result = $manager->searchItems($search);
165 165
 
166
-				if( ( $item = reset( $result ) ) === false ) {
166
+				if (($item = reset($result)) === false) {
167 167
 					continue;
168 168
 				}
169 169
 
170
-				$provider = $manager->getProvider( $item, $code );
170
+				$provider = $manager->getProvider($item, $code);
171 171
 
172
-				if( $provider->isAvailable( $basket ) !== true ) {
172
+				if ($provider->isAvailable($basket) !== true) {
173 173
 					continue;
174 174
 				}
175 175
 
176
-				$provider->addCoupon( $basket );
176
+				$provider->addCoupon($basket);
177 177
 			}
178 178
 		}
179 179
 
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Order including product and addresses
189 189
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order with delivery service added
190 190
 	 */
191
-	protected function addDeliveryService( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
191
+	protected function addDeliveryService(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket)
192 192
 	{
193 193
 		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY;
194 194
 
195
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
196
-		$orderServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' );
195
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
196
+		$orderServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service');
197 197
 
198
-		$search = $serviceManager->createSearch( true );
199
-		$search->setSortations( [$search->sort( '+', 'service.position' )] );
200
-		$search->setConditions( $search->compare( '==', 'service.type.code', $type ) );
198
+		$search = $serviceManager->createSearch(true);
199
+		$search->setSortations([$search->sort('+', 'service.position')]);
200
+		$search->setConditions($search->compare('==', 'service.type.code', $type));
201 201
 
202
-		foreach( $serviceManager->searchItems( $search, ['media', 'price', 'text'] ) as $item )
202
+		foreach ($serviceManager->searchItems($search, ['media', 'price', 'text']) as $item)
203 203
 		{
204
-			$provider = $serviceManager->getProvider( $item, $item->getType() );
204
+			$provider = $serviceManager->getProvider($item, $item->getType());
205 205
 
206
-			if( $provider->isAvailable( $basket ) === true )
206
+			if ($provider->isAvailable($basket) === true)
207 207
 			{
208
-				$orderServiceItem = $orderServiceManager->createItem()->copyFrom( $item );
209
-				$basket->addService( $orderServiceItem, $type );
208
+				$orderServiceItem = $orderServiceManager->createItem()->copyFrom($item);
209
+				$basket->addService($orderServiceItem, $type);
210 210
 
211 211
 				return $basket;
212 212
 			}
@@ -222,30 +222,30 @@  discard block
 block discarded – undo
222 222
 	 * @param string $baseId Unique order base ID
223 223
 	 * @return \Aimeos\MShop\Context\Item\Iface New context object
224 224
 	 */
225
-	protected function createContext( $baseId )
225
+	protected function createContext($baseId)
226 226
 	{
227 227
 		$context = clone $this->getContext();
228 228
 
229
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
230
-		$baseItem = $manager->getItem( $baseId );
229
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
230
+		$baseItem = $manager->getItem($baseId);
231 231
 
232 232
 		$locale = $baseItem->getLocale();
233 233
 		$level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
234 234
 
235
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
236
-		$locale = $manager->bootstrap( $baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level );
235
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'locale');
236
+		$locale = $manager->bootstrap($baseItem->getSiteCode(), $locale->getLanguageId(), $locale->getCurrencyId(), false, $level);
237 237
 
238
-		$context->setLocale( $locale );
238
+		$context->setLocale($locale);
239 239
 
240 240
 		try
241 241
 		{
242
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' );
243
-			$customerItem = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );
242
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'customer');
243
+			$customerItem = $manager->getItem($baseItem->getCustomerId(), ['customer/group']);
244 244
 
245
-			$context->setUserId( $baseItem->getCustomerId() );
246
-			$context->setGroupIds( $customerItem->getGroups() );
245
+			$context->setUserId($baseItem->getCustomerId());
246
+			$context->setGroupIds($customerItem->getGroups());
247 247
 		}
248
-		catch( \Exception $e ) {} // Subscription without account
248
+		catch (\Exception $e) {} // Subscription without account
249 249
 
250 250
 		return $context;
251 251
 	}
@@ -258,39 +258,39 @@  discard block
 block discarded – undo
258 258
 	 * @param \Aimeos\MShop\Subscription\Item\Iface $subscription Subscription item with order base ID and order product ID
259 259
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Complete order with product, addresses and services saved to the storage
260 260
 	 */
261
-	protected function createOrderBase( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription )
261
+	protected function createOrderBase(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Subscription\Item\Iface $subscription)
262 262
 	{
263
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
264
-		$basket = $manager->load( $subscription->getOrderBaseId() );
263
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
264
+		$basket = $manager->load($subscription->getOrderBaseId());
265 265
 
266 266
 		$newBasket = $manager->createItem();
267
-		$newBasket->setCustomerId( $basket->getCustomerId() );
267
+		$newBasket->setCustomerId($basket->getCustomerId());
268 268
 
269
-		foreach( $basket->getProducts() as $orderProduct )
269
+		foreach ($basket->getProducts() as $orderProduct)
270 270
 		{
271
-			if( $orderProduct->getId() === $subscription->getOrderProductId() )
271
+			if ($orderProduct->getId() === $subscription->getOrderProductId())
272 272
 			{
273
-				foreach( $orderProduct->getAttributeItems() as $attrItem ) {
274
-					$attrItem->setId( null );
273
+				foreach ($orderProduct->getAttributeItems() as $attrItem) {
274
+					$attrItem->setId(null);
275 275
 				}
276
-				$newBasket->addProduct( $orderProduct->setId( null ) );
276
+				$newBasket->addProduct($orderProduct->setId(null));
277 277
 			}
278 278
 		}
279 279
 
280
-		foreach( $basket->getAddresses() as $type => $orderAddress ) {
281
-			$newBasket->setAddress( $orderAddress, $type );
280
+		foreach ($basket->getAddresses() as $type => $orderAddress) {
281
+			$newBasket->setAddress($orderAddress, $type);
282 282
 		}
283 283
 
284 284
 		$type = \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT;
285 285
 
286
-		foreach( $basket->getService( $type ) as $orderService ) {
287
-			$newBasket->addService( $orderService, $type );
286
+		foreach ($basket->getService($type) as $orderService) {
287
+			$newBasket->addService($orderService, $type);
288 288
 		}
289 289
 
290
-		$newBasket = $this->addDeliveryService( $context, $newBasket );
291
-		$newBasket = $this->addBasketCoupons( $context, $newBasket, array_keys( $basket->getCoupons() ) );
290
+		$newBasket = $this->addDeliveryService($context, $newBasket);
291
+		$newBasket = $this->addBasketCoupons($context, $newBasket, array_keys($basket->getCoupons()));
292 292
 
293
-		return $manager->store( $newBasket );
293
+		return $manager->store($newBasket);
294 294
 	}
295 295
 
296 296
 
@@ -301,15 +301,15 @@  discard block
 block discarded – undo
301 301
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services saved to the storage
302 302
 	 * @return \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order saved to the storage
303 303
 	 */
304
-	protected function createOrderInvoice( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket )
304
+	protected function createOrderInvoice(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket)
305 305
 	{
306
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
306
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'order');
307 307
 
308 308
 		$item = $manager->createItem();
309
-		$item->setBaseId( $basket->getId() );
310
-		$item->setType( 'subscription' );
309
+		$item->setBaseId($basket->getId());
310
+		$item->setType('subscription');
311 311
 
312
-		return $manager->saveItem( $item );
312
+		return $manager->saveItem($item);
313 313
 	}
314 314
 
315 315
 
@@ -320,17 +320,17 @@  discard block
 block discarded – undo
320 320
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Complete order with product, addresses and services
321 321
 	 * @param \Aimeos\MShop\Order\Item\Iface New invoice item associated to the order
322 322
 	 */
323
-	protected function createPayment( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
324
-		\Aimeos\MShop\Order\Item\Iface $invoice )
323
+	protected function createPayment(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Order\Item\Base\Iface $basket,
324
+		\Aimeos\MShop\Order\Item\Iface $invoice)
325 325
 	{
326
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
326
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'service');
327 327
 
328
-		foreach( $basket->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT ) as $service )
328
+		foreach ($basket->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_PAYMENT) as $service)
329 329
 		{
330
-			$item = $manager->getItem( $service->getServiceId() );
331
-			$provider = $manager->getProvider( $item, 'payment' );
330
+			$item = $manager->getItem($service->getServiceId());
331
+			$provider = $manager->getProvider($item, 'payment');
332 332
 
333
-			$provider->repay( $invoice );
333
+			$provider->repay($invoice);
334 334
 		}
335 335
 	}
336 336
 }
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.
common/src/Controller/Common/Catalog/Import/Csv/Processor/Text/Standard.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@
 block discarded – undo
108 108
 				$listItem = $listMap[$content][$type][$typecode];
109 109
 				$refItem = $listItem->getRefItem();
110 110
 				unset( $listItems[ $listItem->getId() ] );
111
-			}
112
-			else
111
+			} else
113 112
 			{
114 113
 				$listItem = $listManager->createItem( $typecode, 'text' );
115 114
 				$refItem = $manager->createItem( $type, 'catalog' );
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 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,53 +77,53 @@  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
 
85 85
 		$listMap = [];
86
-		$map = $this->getMappedChunk( $data, $this->getMapping() );
87
-		$listItems = $catalog->getListItems( 'text', $this->listTypes );
86
+		$map = $this->getMappedChunk($data, $this->getMapping());
87
+		$listItems = $catalog->getListItems('text', $this->listTypes);
88 88
 
89
-		foreach( $listItems as $listItem )
89
+		foreach ($listItems as $listItem)
90 90
 		{
91
-			if( ( $refItem = $listItem->getRefItem() ) !== null ) {
92
-				$listMap[ $refItem->getContent() ][ $refItem->getType() ][ $listItem->getType() ] = $listItem;
91
+			if (($refItem = $listItem->getRefItem()) !== null) {
92
+				$listMap[$refItem->getContent()][$refItem->getType()][$listItem->getType()] = $listItem;
93 93
 			}
94 94
 		}
95 95
 
96
-		foreach( $map as $pos => $list )
96
+		foreach ($map as $pos => $list)
97 97
 		{
98
-			if( $this->checkEntry( $list ) === false ) {
98
+			if ($this->checkEntry($list) === false) {
99 99
 				continue;
100 100
 			}
101 101
 
102
-			$content = trim( $list['text.content'] );
103
-			$type = trim( isset( $list['text.type'] ) ? $list['text.type'] : 'name' );
104
-			$typecode = trim( isset( $list['catalog.lists.type'] ) ? $list['catalog.lists.type'] : 'default' );
102
+			$content = trim($list['text.content']);
103
+			$type = trim(isset($list['text.type']) ? $list['text.type'] : 'name');
104
+			$typecode = trim(isset($list['catalog.lists.type']) ? $list['catalog.lists.type'] : 'default');
105 105
 
106
-			if( isset( $listMap[$content][$type][$typecode] ) )
106
+			if (isset($listMap[$content][$type][$typecode]))
107 107
 			{
108 108
 				$listItem = $listMap[$content][$type][$typecode];
109 109
 				$refItem = $listItem->getRefItem();
110
-				unset( $listItems[ $listItem->getId() ] );
110
+				unset($listItems[$listItem->getId()]);
111 111
 			}
112 112
 			else
113 113
 			{
114
-				$listItem = $listManager->createItem( $typecode, 'text' );
115
-				$refItem = $manager->createItem( $type, 'catalog' );
114
+				$listItem = $listManager->createItem($typecode, 'text');
115
+				$refItem = $manager->createItem($type, 'catalog');
116 116
 			}
117 117
 
118
-			$refItem->fromArray( $this->addItemDefaults( $list ) );
119
-			$listItem->fromArray( $this->addListItemDefaults( $list, $pos ) );
118
+			$refItem->fromArray($this->addItemDefaults($list));
119
+			$listItem->fromArray($this->addListItemDefaults($list, $pos));
120 120
 
121
-			$catalog->addListItem( 'text', $listItem, $refItem );
121
+			$catalog->addListItem('text', $listItem, $refItem);
122 122
 		}
123 123
 
124
-		$catalog->deleteListItems( $listItems, true );
124
+		$catalog->deleteListItems($listItems, true);
125 125
 
126
-		return $this->getObject()->process( $catalog, $data );
126
+		return $this->getObject()->process($catalog, $data);
127 127
 	}
128 128
 
129 129
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 	 * @param array $list Associative list of domain item keys and their values, e.g. "text.status" => 1
134 134
 	 * @return array Given associative list enriched by default values if they were not already set
135 135
 	 */
136
-	protected function addItemDefaults( array $list )
136
+	protected function addItemDefaults(array $list)
137 137
 	{
138
-		if( !isset( $list['text.label'] ) ) {
139
-			$list['text.label'] = mb_strcut( trim( $list['text.content'] ), 0, 255 );
138
+		if (!isset($list['text.label'])) {
139
+			$list['text.label'] = mb_strcut(trim($list['text.content']), 0, 255);
140 140
 		}
141 141
 
142
-		if( !isset( $list['text.status'] ) ) {
142
+		if (!isset($list['text.status'])) {
143 143
 			$list['text.status'] = 1;
144 144
 		}
145 145
 
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 	 * @param array $list Associative list of key/value pairs from the mapping
154 154
 	 * @return boolean True if valid, false if not
155 155
 	 */
156
-	protected function checkEntry( array $list )
156
+	protected function checkEntry(array $list)
157 157
 	{
158
-		if( !isset( $list['text.content'] ) || trim( $list['text.content'] ) === '' || isset( $list['catalog.lists.type'] )
159
-			&& $this->listTypes !== null && !in_array( trim( $list['catalog.lists.type'] ), (array) $this->listTypes )
158
+		if (!isset($list['text.content']) || trim($list['text.content']) === '' || isset($list['catalog.lists.type'])
159
+			&& $this->listTypes !== null && !in_array(trim($list['catalog.lists.type']), (array) $this->listTypes)
160 160
 		) {
161 161
 			return false;
162 162
 		}
Please login to merge, or discard this patch.