Completed
Push — master ( 08fedb...6dd458 )
by Aimeos
05:10
created
common/src/Controller/Common/Subscription/Export/Csv/Processor/Base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
30 30
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
31 31
 	 */
32
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping )
32
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping)
33 33
 	{
34 34
 		$this->context = $context;
35 35
 		$this->mapping = $mapping;
Please login to merge, or discard this patch.
common/src/Controller/Common/Subscription/Export/Csv/Processor/Iface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
26 26
 	 * @param array $mapping Associative list of field position in CSV as key and domain item key as value
27 27
 	 */
28
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context, array $mapping );
28
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context, array $mapping);
29 29
 
30 30
 
31 31
 	/**
@@ -35,5 +35,5 @@  discard block
 block discarded – undo
35 35
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items
36 36
 	 * @return array Two dimensional associative list of order data representing the lines in CSV
37 37
 	 */
38
-	public function process( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order );
38
+	public function process(\Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order);
39 39
 }
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
Common/Subscription/Export/Csv/Processor/Subscription/Standard.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,21 +40,21 @@
 block discarded – undo
40 40
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $order Full order with associated items
41 41
 	 * @return array Two dimensional associative list of subscription data representing the lines in CSV
42 42
 	 */
43
-	public function process( \Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order )
43
+	public function process(\Aimeos\MShop\Subscription\Item\Iface $subscription, \Aimeos\MShop\Order\Item\Base\Iface $order)
44 44
 	{
45 45
 		$result = [];
46 46
 		$list = $subscription->toArray() + $order->toArray();
47 47
 
48
-		foreach( $this->getMapping() as $pos => $key )
48
+		foreach ($this->getMapping() as $pos => $key)
49 49
 		{
50
-			if( array_key_exists( $key, $list ) ) {
50
+			if (array_key_exists($key, $list)) {
51 51
 				$result[$pos] = $list[$key];
52 52
 			} else {
53 53
 				$result[$pos] = '';
54 54
 			}
55 55
 		}
56 56
 
57
-		ksort( $result );
57
+		ksort($result);
58 58
 
59 59
 		return [$result];
60 60
 	}
Please login to merge, or discard this patch.
Common/Subscription/Export/Csv/Processor/Address/StandardTest.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -38,77 +38,77 @@
 block discarded – undo
38 38
 		);
39 39
 
40 40
 
41
-		$object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Address\Standard( $context, $mapping );
42
-
43
-		$subscription = $this->getSubscription( $context );
44
-		$order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $subscription->getOrderBaseId() );
45
-
46
-		$data = $object->process( $subscription, $order );
47
-
48
-
49
-		$this->assertEquals( 2, count( $data ) );
50
-
51
-		$this->assertEquals( 21, count( $data[0] ) );
52
-		$this->assertEquals( 'payment', $data[0][0] );
53
-		$this->assertEquals( 'mr', $data[0][1] );
54
-		$this->assertEquals( '', $data[0][2] );
55
-		$this->assertEquals( '', $data[0][3] );
56
-		$this->assertEquals( '', $data[0][4] );
57
-		$this->assertEquals( 'Our', $data[0][5] );
58
-		$this->assertEquals( 'Unittest', $data[0][6] );
59
-		$this->assertEquals( 'Durchschnitt', $data[0][7] );
60
-		$this->assertEquals( '1', $data[0][8] );
61
-		$this->assertEquals( '', $data[0][9] );
62
-		$this->assertEquals( '20146', $data[0][10] );
63
-		$this->assertEquals( 'Hamburg', $data[0][11] );
64
-		$this->assertEquals( 'Hamburg', $data[0][12] );
65
-		$this->assertEquals( 'DE', $data[0][13] );
66
-		$this->assertEquals( 'de', $data[0][14] );
67
-		$this->assertEquals( '055544332211', $data[0][15] );
68
-		$this->assertEquals( '055544332213', $data[0][16] );
69
-		$this->assertEquals( '[email protected]', $data[0][17] );
70
-		$this->assertEquals( 'www.metaways.net', $data[0][18] );
71
-		$this->assertEquals( '11.000000', $data[0][19] );
72
-		$this->assertEquals( '52.000000', $data[0][20] );
73
-
74
-		$this->assertEquals( 21, count( $data[1] ) );
75
-		$this->assertEquals( 'delivery', $data[1][0] );
76
-		$this->assertEquals( 'mr', $data[1][1] );
77
-		$this->assertEquals( 'Example company', $data[1][2] );
78
-		$this->assertEquals( 'DE999999999', $data[1][3] );
79
-		$this->assertEquals( 'Dr.', $data[1][4] );
80
-		$this->assertEquals( 'Our', $data[1][5] );
81
-		$this->assertEquals( 'Unittest', $data[1][6] );
82
-		$this->assertEquals( 'Pickhuben', $data[1][7] );
83
-		$this->assertEquals( '2-4', $data[1][8] );
84
-		$this->assertEquals( '', $data[1][9] );
85
-		$this->assertEquals( '20457', $data[1][10] );
86
-		$this->assertEquals( 'Hamburg', $data[1][11] );
87
-		$this->assertEquals( 'Hamburg', $data[1][12] );
88
-		$this->assertEquals( 'DE', $data[1][13] );
89
-		$this->assertEquals( 'de', $data[1][14] );
90
-		$this->assertEquals( '055544332211', $data[1][15] );
91
-		$this->assertEquals( '055544332212', $data[1][16] );
92
-		$this->assertEquals( '[email protected]', $data[1][17] );
93
-		$this->assertEquals( 'www.example.com', $data[1][18] );
94
-		$this->assertEquals( '10.000000', $data[1][19] );
95
-		$this->assertEquals( '50.000000', $data[1][20] );
41
+		$object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Address\Standard($context, $mapping);
42
+
43
+		$subscription = $this->getSubscription($context);
44
+		$order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($subscription->getOrderBaseId());
45
+
46
+		$data = $object->process($subscription, $order);
47
+
48
+
49
+		$this->assertEquals(2, count($data));
50
+
51
+		$this->assertEquals(21, count($data[0]));
52
+		$this->assertEquals('payment', $data[0][0]);
53
+		$this->assertEquals('mr', $data[0][1]);
54
+		$this->assertEquals('', $data[0][2]);
55
+		$this->assertEquals('', $data[0][3]);
56
+		$this->assertEquals('', $data[0][4]);
57
+		$this->assertEquals('Our', $data[0][5]);
58
+		$this->assertEquals('Unittest', $data[0][6]);
59
+		$this->assertEquals('Durchschnitt', $data[0][7]);
60
+		$this->assertEquals('1', $data[0][8]);
61
+		$this->assertEquals('', $data[0][9]);
62
+		$this->assertEquals('20146', $data[0][10]);
63
+		$this->assertEquals('Hamburg', $data[0][11]);
64
+		$this->assertEquals('Hamburg', $data[0][12]);
65
+		$this->assertEquals('DE', $data[0][13]);
66
+		$this->assertEquals('de', $data[0][14]);
67
+		$this->assertEquals('055544332211', $data[0][15]);
68
+		$this->assertEquals('055544332213', $data[0][16]);
69
+		$this->assertEquals('[email protected]', $data[0][17]);
70
+		$this->assertEquals('www.metaways.net', $data[0][18]);
71
+		$this->assertEquals('11.000000', $data[0][19]);
72
+		$this->assertEquals('52.000000', $data[0][20]);
73
+
74
+		$this->assertEquals(21, count($data[1]));
75
+		$this->assertEquals('delivery', $data[1][0]);
76
+		$this->assertEquals('mr', $data[1][1]);
77
+		$this->assertEquals('Example company', $data[1][2]);
78
+		$this->assertEquals('DE999999999', $data[1][3]);
79
+		$this->assertEquals('Dr.', $data[1][4]);
80
+		$this->assertEquals('Our', $data[1][5]);
81
+		$this->assertEquals('Unittest', $data[1][6]);
82
+		$this->assertEquals('Pickhuben', $data[1][7]);
83
+		$this->assertEquals('2-4', $data[1][8]);
84
+		$this->assertEquals('', $data[1][9]);
85
+		$this->assertEquals('20457', $data[1][10]);
86
+		$this->assertEquals('Hamburg', $data[1][11]);
87
+		$this->assertEquals('Hamburg', $data[1][12]);
88
+		$this->assertEquals('DE', $data[1][13]);
89
+		$this->assertEquals('de', $data[1][14]);
90
+		$this->assertEquals('055544332211', $data[1][15]);
91
+		$this->assertEquals('055544332212', $data[1][16]);
92
+		$this->assertEquals('[email protected]', $data[1][17]);
93
+		$this->assertEquals('www.example.com', $data[1][18]);
94
+		$this->assertEquals('10.000000', $data[1][19]);
95
+		$this->assertEquals('50.000000', $data[1][20]);
96 96
 	}
97 97
 
98 98
 
99
-	protected function getSubscription( $context )
99
+	protected function getSubscription($context)
100 100
 	{
101
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
101
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
102 102
 
103 103
 		$search = $manager->createSearch();
104
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
104
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
105 105
 
106
-		$items = $manager->searchItems( $search );
106
+		$items = $manager->searchItems($search);
107 107
 
108
-		if( ( $item = reset( $items ) ) !== false ) {
108
+		if (($item = reset($items)) !== false) {
109 109
 			return $item;
110 110
 		}
111 111
 
112
-		throw new \Exception( 'No subscription item found' );
112
+		throw new \Exception('No subscription item found');
113 113
 	}
114 114
 }
Please login to merge, or discard this patch.
Common/Subscription/Export/Csv/Processor/Subscription/StandardTest.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -20,36 +20,36 @@
 block discarded – undo
20 20
 		);
21 21
 
22 22
 
23
-		$object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Subscription\Standard( $context, $mapping );
23
+		$object = new \Aimeos\Controller\Common\Subscription\Export\Csv\Processor\Subscription\Standard($context, $mapping);
24 24
 
25
-		$subscription = $this->getSubscription( $context );
26
-		$order = \Aimeos\MShop\Factory::createManager( $context, 'order/base' )->load( $subscription->getOrderBaseId() );
25
+		$subscription = $this->getSubscription($context);
26
+		$order = \Aimeos\MShop\Factory::createManager($context, 'order/base')->load($subscription->getOrderBaseId());
27 27
 
28
-		$data = $object->process( $subscription, $order );
28
+		$data = $object->process($subscription, $order);
29 29
 
30 30
 
31
-		$this->assertEquals( 1, count( $data ) );
31
+		$this->assertEquals(1, count($data));
32 32
 
33
-		$this->assertEquals( 3, count( $data[0] ) );
34
-		$this->assertEquals( 'P0Y1M0W0D', $data[0][0] );
35
-		$this->assertEquals( '2000-01-01', $data[0][1] );
36
-		$this->assertEquals( '2010-01-01', $data[0][2] );
33
+		$this->assertEquals(3, count($data[0]));
34
+		$this->assertEquals('P0Y1M0W0D', $data[0][0]);
35
+		$this->assertEquals('2000-01-01', $data[0][1]);
36
+		$this->assertEquals('2010-01-01', $data[0][2]);
37 37
 	}
38 38
 
39 39
 
40
-	protected function getSubscription( $context )
40
+	protected function getSubscription($context)
41 41
 	{
42
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'subscription' );
42
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'subscription');
43 43
 
44 44
 		$search = $manager->createSearch();
45
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
45
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
46 46
 
47
-		$items = $manager->searchItems( $search );
47
+		$items = $manager->searchItems($search);
48 48
 
49
-		if( ( $item = reset( $items ) ) !== false ) {
49
+		if (($item = reset($items)) !== false) {
50 50
 			return $item;
51 51
 		}
52 52
 
53
-		throw new \Exception( 'No subscription item found' );
53
+		throw new \Exception('No subscription item found');
54 54
 	}
55 55
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Export/Csv/Standard.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,8 +121,7 @@
 block discarded – undo
121 121
 				}
122 122
 
123 123
 				$this->export( $processors, $data, $maxcnt );
124
-			}
125
-			catch( \Exception $e )
124
+			} catch( \Exception $e )
126 125
 			{
127 126
 				$logger->log( 'Subscription export error: ' . $e->getMessage() );
128 127
 				$logger->log( $e->getTraceAsString() );
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 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 export CSV' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription export CSV');
32 32
 	}
33 33
 
34 34
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function getDescription()
41 41
 	{
42
-		return $this->getContext()->getI18n()->dt( 'controller/jobs', 'Exports subscriptions to CSV file' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Exports subscriptions to CSV file');
43 43
 	}
44 44
 
45 45
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		 * @category Developer
74 74
 		 * @see controller/common/subscription/export/csv/max-size
75 75
 		 */
76
-		$mappings = $config->get( 'controller/common/subscription/export/csv/mapping', $mappings );
76
+		$mappings = $config->get('controller/common/subscription/export/csv/mapping', $mappings);
77 77
 
78 78
 		/** controller/jobs/subscription/export/csv/mapping
79 79
 		 * List of mappings between the position in the CSV file and item keys
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 * @category Developer
89 89
 		 * @see controller/common/subscription/export/csv/max-size
90 90
 		 */
91
-		$mappings = $config->get( 'controller/jobs/subscription/export/csv/mapping', $mappings );
91
+		$mappings = $config->get('controller/jobs/subscription/export/csv/mapping', $mappings);
92 92
 
93 93
 
94 94
 		/** controller/common/subscription/export/csv/max-size
@@ -106,29 +106,29 @@  discard block
 block discarded – undo
106 106
 		 * @category Developer
107 107
 		 * @see controller/common/subscription/export/csv/mapping
108 108
 		 */
109
-		$maxcnt = (int) $config->get( 'controller/common/subscription/export/csv/max-size', 1000 );
109
+		$maxcnt = (int) $config->get('controller/common/subscription/export/csv/max-size', 1000);
110 110
 
111 111
 
112
-		$processors = $this->getProcessors( $mappings );
113
-		$mq = $context->getMessageQueueManager()->get( 'mq-admin' )->getQueue( 'subscription-export' );
112
+		$processors = $this->getProcessors($mappings);
113
+		$mq = $context->getMessageQueueManager()->get('mq-admin')->getQueue('subscription-export');
114 114
 
115
-		while( ( $msg = $mq->get() ) !== null )
115
+		while (($msg = $mq->get()) !== null)
116 116
 		{
117 117
 			try
118 118
 			{
119
-				if( ( $data = json_decode( $msg->getBody(), true ) ) === null ) {
120
-					throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid message: %1$s', $msg->getBody() ) );
119
+				if (($data = json_decode($msg->getBody(), true)) === null) {
120
+					throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid message: %1$s', $msg->getBody()));
121 121
 				}
122 122
 
123
-				$this->export( $processors, $data, $maxcnt );
123
+				$this->export($processors, $data, $maxcnt);
124 124
 			}
125
-			catch( \Exception $e )
125
+			catch (\Exception $e)
126 126
 			{
127
-				$logger->log( 'Subscription export error: ' . $e->getMessage() );
128
-				$logger->log( $e->getTraceAsString() );
127
+				$logger->log('Subscription export error: ' . $e->getMessage());
128
+				$logger->log($e->getTraceAsString());
129 129
 			}
130 130
 
131
-			$mq->del( $msg );
131
+			$mq->del($msg);
132 132
 		}
133 133
 	}
134 134
 
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item
140 140
 	 * @param string $path Absolute path to the exported file
141 141
 	 */
142
-	protected function addJob( $context, $path )
142
+	protected function addJob($context, $path)
143 143
 	{
144
-		$manager = \Aimeos\MAdmin\Factory::createManager( $context, 'job' );
144
+		$manager = \Aimeos\MAdmin\Factory::createManager($context, 'job');
145 145
 
146 146
 		$item = $manager->createItem();
147
-		$item->setResult( ['file' => $path] );
148
-		$item->setLabel( $path );
147
+		$item->setResult(['file' => $path]);
148
+		$item->setLabel($path);
149 149
 
150
-		$manager->saveItem( $item, false );
150
+		$manager->saveItem($item, false);
151 151
 	}
152 152
 
153 153
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * @see controller/jobs/subscription/export/csv/container/content
178 178
 		 * @see controller/jobs/subscription/export/csv/container/options
179 179
 		 */
180
-		$location = $config->get( 'controller/jobs/subscription/export/csv/location', sys_get_temp_dir() );
180
+		$location = $config->get('controller/jobs/subscription/export/csv/location', sys_get_temp_dir());
181 181
 
182 182
 		/** controller/jobs/subscription/export/csv/container/type
183 183
 		 * Nave of the container type to read the data from
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		 * @see controller/jobs/subscription/export/csv/container/content
201 201
 		 * @see controller/jobs/subscription/export/csv/container/options
202 202
 		 */
203
-		$container = $config->get( 'controller/jobs/subscription/export/csv/container/type', 'Directory' );
203
+		$container = $config->get('controller/jobs/subscription/export/csv/container/type', 'Directory');
204 204
 
205 205
 		/** controller/jobs/subscription/export/csv/container/content
206 206
 		 * Name of the content type inside the container to read the data from
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		 * @see controller/jobs/subscription/export/csv/container/type
222 222
 		 * @see controller/jobs/subscription/export/csv/container/options
223 223
 		 */
224
-		$content = $config->get( 'controller/jobs/subscription/export/csv/container/content', 'CSV' );
224
+		$content = $config->get('controller/jobs/subscription/export/csv/container/content', 'CSV');
225 225
 
226 226
 		/** controller/jobs/subscription/export/csv/container/options
227 227
 		 * List of file container options for the subscription export files
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		 * @see controller/jobs/subscription/export/csv/container/content
240 240
 		 * @see controller/jobs/subscription/export/csv/container/type
241 241
 		 */
242
-		$options = $config->get( 'controller/jobs/subscription/export/csv/container/options', [] );
242
+		$options = $config->get('controller/jobs/subscription/export/csv/container/options', []);
243 243
 
244
-		return \Aimeos\MW\Container\Factory::getContainer( $location, $container, $content, $options );
244
+		return \Aimeos\MW\Container\Factory::getContainer($location, $container, $content, $options);
245 245
 	}
246 246
 
247 247
 
@@ -253,56 +253,56 @@  discard block
 block discarded – undo
253 253
 	 * @param integer $maxcnt Maximum number of retrieved subscriptions at once
254 254
 	 * @return string Path of the file containing the exported data
255 255
 	 */
256
-	protected function export( array $processors, $msg, $maxcnt )
256
+	protected function export(array $processors, $msg, $maxcnt)
257 257
 	{
258
-		$lcontext = $this->getLocaleContext( $msg );
258
+		$lcontext = $this->getLocaleContext($msg);
259 259
 		$baseRef = ['order/base/address', 'order/base/product'];
260 260
 
261
-		$manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'subscription' );
262
-		$baseManager = \Aimeos\MShop\Factory::createManager( $lcontext, 'order/base' );
261
+		$manager = \Aimeos\MShop\Factory::createManager($lcontext, 'subscription');
262
+		$baseManager = \Aimeos\MShop\Factory::createManager($lcontext, 'order/base');
263 263
 
264 264
 		$container = $this->getContainer();
265
-		$content = $container->create( 'subscription-export_' . date( 'Y-m-d_H-i-s' ) );
266
-		$search = $this->initCriteria( $manager->createSearch()->setSlice( 0, 0x7fffffff ), $msg );
265
+		$content = $container->create('subscription-export_' . date('Y-m-d_H-i-s'));
266
+		$search = $this->initCriteria($manager->createSearch()->setSlice(0, 0x7fffffff), $msg);
267 267
 		$start = 0;
268 268
 
269 269
 		do
270 270
 		{
271 271
 			$baseIds = [];
272
-			$search->setSlice( $start, $maxcnt );
273
-			$items = $manager->searchItems( $search );
272
+			$search->setSlice($start, $maxcnt);
273
+			$items = $manager->searchItems($search);
274 274
 
275
-			foreach( $items as $item ) {
275
+			foreach ($items as $item) {
276 276
 				$baseIds[] = $item->getOrderBaseId();
277 277
 			}
278 278
 
279 279
 			$baseSearch = $baseManager->createSearch();
280
-			$baseSearch->setConditions( $baseSearch->compare( '==', 'order.base.id', $baseIds ) );
281
-			$baseSearch->setSlice( 0, count( $baseIds ) );
280
+			$baseSearch->setConditions($baseSearch->compare('==', 'order.base.id', $baseIds));
281
+			$baseSearch->setSlice(0, count($baseIds));
282 282
 
283
-			$baseItems = $baseManager->searchItems( $baseSearch, $baseRef );
283
+			$baseItems = $baseManager->searchItems($baseSearch, $baseRef);
284 284
 
285
-			foreach( $items as $id => $item )
285
+			foreach ($items as $id => $item)
286 286
 			{
287
-				foreach( $processors as $type => $processor )
287
+				foreach ($processors as $type => $processor)
288 288
 				{
289
-					foreach( $processor->process( $item, $baseItems[$item->getOrderBaseId()] ) as $line ) {
290
-						$content->add( [0 => $type, 1 => $id] + $line );
289
+					foreach ($processor->process($item, $baseItems[$item->getOrderBaseId()]) as $line) {
290
+						$content->add([0 => $type, 1 => $id] + $line);
291 291
 					}
292 292
 				}
293 293
 			}
294 294
 
295
-			$count = count( $items );
295
+			$count = count($items);
296 296
 			$start += $count;
297 297
 		}
298
-		while( $count === $search->getSliceSize() );
298
+		while ($count === $search->getSliceSize());
299 299
 
300 300
 		$path = $content->getResource();
301
-		$container->add( $content );
301
+		$container->add($content);
302 302
 		$container->close();
303 303
 
304
-		$path = $this->moveFile( $lcontext, $path );
305
-		$this->addJob( $lcontext, $path );
304
+		$path = $this->moveFile($lcontext, $path);
305
+		$this->addJob($lcontext, $path);
306 306
 	}
307 307
 
308 308
 
@@ -312,15 +312,15 @@  discard block
 block discarded – undo
312 312
 	 * @param array $msg Message data including a "sitecode" value
313 313
 	 * @return \Aimeos\MShop\Context\Item\Iface New context item with updated locale
314 314
 	 */
315
-	protected function getLocaleContext( array $msg )
315
+	protected function getLocaleContext(array $msg)
316 316
 	{
317 317
 		$lcontext = clone $this->getContext();
318
-		$manager = \Aimeos\MShop\Factory::createManager( $lcontext, 'locale' );
318
+		$manager = \Aimeos\MShop\Factory::createManager($lcontext, 'locale');
319 319
 
320
-		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
321
-		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE );
320
+		$sitecode = (isset($msg['sitecode']) ? $msg['sitecode'] : 'default');
321
+		$localeItem = $manager->bootstrap($sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE);
322 322
 
323
-		return $lcontext->setLocale( $localeItem );
323
+		return $lcontext->setLocale($localeItem);
324 324
 	}
325 325
 
326 326
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 	 * @param array $msg Message data
332 332
 	 * @return \Aimeos\MW\Criteria\Iface Initialized criteria object
333 333
 	 */
334
-	protected function initCriteria( \Aimeos\MW\Criteria\Iface $criteria, array $msg )
334
+	protected function initCriteria(\Aimeos\MW\Criteria\Iface $criteria, array $msg)
335 335
 	{
336
-		if( isset( $msg['filter'] ) ) {
337
-			$criteria->setConditions( $criteria->toConditions( $msg['filter'] ) );
336
+		if (isset($msg['filter'])) {
337
+			$criteria->setConditions($criteria->toConditions($msg['filter']));
338 338
 		}
339 339
 
340
-		if( isset( $msg['sort'] ) ) {
341
-			$criteria->setSortations( $criteria->toSortations( $msg['sort'] ) );
340
+		if (isset($msg['sort'])) {
341
+			$criteria->setSortations($criteria->toSortations($msg['sort']));
342 342
 		}
343 343
 
344 344
 		return $criteria;
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 	 * @param string $path Absolute path to the exported file
353 353
 	 * @return string Relative path of the file in the storage
354 354
 	 */
355
-	protected function moveFile( $context, $path )
355
+	protected function moveFile($context, $path)
356 356
 	{
357
-		$filename = basename( $path );
358
-		$context->getFileSystemManager()->get( 'fs-admin' )->writef( $filename, $path );
357
+		$filename = basename($path);
358
+		$context->getFileSystemManager()->get('fs-admin')->writef($filename, $path);
359 359
 
360
-		unlink( $path );
360
+		unlink($path);
361 361
 		return $filename;
362 362
 	}
363 363
 }
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Export/Csv/Factory.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string|null $name Name of the controller or "Standard" if null
30 30
 	 * @return \Aimeos\Controller\Jobs\Iface New controller object
31 31
 	 */
32
-	public static function createController( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null )
32
+	public static function createController(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\Bootstrap $aimeos, $name = null)
33 33
 	{
34 34
 		/** controller/jobs/subscription/export/csv/name
35 35
 		 * Class name of the used subscription suggestions scheduler controller implementation
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 		 * @since 2018.04
65 65
 		 * @category Developer
66 66
 		 */
67
-		if ( $name === null ) {
67
+		if ($name === null) {
68 68
 			$name = $context->getConfig()->get('controller/jobs/subscription/export/csv/name', 'Standard');
69 69
 		}
70 70
 
71
-		if ( ctype_alnum($name) === false )
71
+		if (ctype_alnum($name) === false)
72 72
 		{
73 73
 			$classname = is_string($name) ? '\\Aimeos\\Controller\\Jobs\\Subscription\\Export\\Csv\\' . $name : '<not a string>';
74
-			throw new \Aimeos\Controller\Jobs\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) );
74
+			throw new \Aimeos\Controller\Jobs\Exception(sprintf('Invalid characters in class name "%1$s"', $classname));
75 75
 		}
76 76
 
77 77
 		$iface = '\\Aimeos\\Controller\\Jobs\\Iface';
78 78
 		$classname = '\\Aimeos\\Controller\\Jobs\\Subscription\\Export\\Csv\\' . $name;
79 79
 
80
-		$controller = self::createControllerBase( $context, $aimeos, $classname, $iface );
80
+		$controller = self::createControllerBase($context, $aimeos, $classname, $iface);
81 81
 
82 82
 		/** controller/jobs/subscription/export/csv/decorators/excludes
83 83
 		 * Excludes decorators added by the "common" option from the subscription export CSV job controller
@@ -154,6 +154,6 @@  discard block
 block discarded – undo
154 154
 		 * @see controller/jobs/subscription/export/csv/decorators/excludes
155 155
 		 * @see controller/jobs/subscription/export/csv/decorators/global
156 156
 		 */
157
-		return self::addControllerDecorators( $context, $aimeos, $controller, 'subscription/export/csv' );
157
+		return self::addControllerDecorators($context, $aimeos, $controller, 'subscription/export/csv');
158 158
 	}
159 159
 }
160 160
\ No newline at end of file
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Export/Csv/StandardTest.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -20,95 +20,95 @@
 block discarded – undo
20 20
 		$this->context = \TestHelperJobs::getContext();
21 21
 		$aimeos = \TestHelperJobs::getAimeos();
22 22
 
23
-		$this->object = new \Aimeos\Controller\Jobs\Subscription\Export\Csv\Standard( $this->context, $aimeos );
23
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Export\Csv\Standard($this->context, $aimeos);
24 24
 	}
25 25
 
26 26
 
27 27
 	protected function tearDown()
28 28
 	{
29
-		unset( $this->object, $this->context );
29
+		unset($this->object, $this->context);
30 30
 	}
31 31
 
32 32
 
33 33
 	public function testGetName()
34 34
 	{
35
-		$this->assertEquals( 'Subscription export CSV', $this->object->getName() );
35
+		$this->assertEquals('Subscription export CSV', $this->object->getName());
36 36
 	}
37 37
 
38 38
 
39 39
 	public function testGetDescription()
40 40
 	{
41
-		$this->assertEquals( 'Exports subscriptions to CSV file', $this->object->getDescription() );
41
+		$this->assertEquals('Exports subscriptions to CSV file', $this->object->getDescription());
42 42
 	}
43 43
 
44 44
 
45 45
 	public function testRun()
46 46
 	{
47
-		$mqmStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Manager\\Standard' )
48
-			->setConstructorArgs( [$this->context->getConfig()] )
49
-			->setMethods( ['get'] )
47
+		$mqmStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Manager\\Standard')
48
+			->setConstructorArgs([$this->context->getConfig()])
49
+			->setMethods(['get'])
50 50
 			->getMock();
51 51
 
52
-		$mqStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Standard' )
52
+		$mqStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Standard')
53 53
 			->disableOriginalConstructor()
54
-			->setMethods( ['getQueue'] )
54
+			->setMethods(['getQueue'])
55 55
 			->getMock();
56 56
 
57
-		$queueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Queue\\Standard' )
57
+		$queueStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Queue\\Standard')
58 58
 			->disableOriginalConstructor()
59
-			->setMethods( ['del', 'get'] )
59
+			->setMethods(['del', 'get'])
60 60
 			->getMock();
61 61
 
62
-		$msgStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Message\\Standard' )
62
+		$msgStub = $this->getMockBuilder('\\Aimeos\\MW\\MQueue\\Message\\Standard')
63 63
 			->disableOriginalConstructor()
64
-			->setMethods( ['getBody'] )
64
+			->setMethods(['getBody'])
65 65
 			->getMock();
66 66
 
67 67
 
68
-		$this->context->setMessageQueueManager( $mqmStub );
68
+		$this->context->setMessageQueueManager($mqmStub);
69 69
 
70 70
 
71
-		$mqmStub->expects( $this->once() )->method( 'get' )
72
-			->will( $this->returnValue( $mqStub ) );
71
+		$mqmStub->expects($this->once())->method('get')
72
+			->will($this->returnValue($mqStub));
73 73
 
74
-		$mqStub->expects( $this->once() )->method( 'getQueue' )
75
-			->will( $this->returnValue( $queueStub ) );
74
+		$mqStub->expects($this->once())->method('getQueue')
75
+			->will($this->returnValue($queueStub));
76 76
 
77
-		$queueStub->expects( $this->exactly( 2 ) )->method( 'get' )
78
-			->will( $this->onConsecutiveCalls( $msgStub, null ) );
77
+		$queueStub->expects($this->exactly(2))->method('get')
78
+			->will($this->onConsecutiveCalls($msgStub, null));
79 79
 
80
-		$queueStub->expects( $this->once() )->method( 'del' );
80
+		$queueStub->expects($this->once())->method('del');
81 81
 
82
-		$msgStub->expects( $this->once() )->method( 'getBody' )
83
-			->will( $this->returnValue( '{"sitecode":"unittest"}' ) );
82
+		$msgStub->expects($this->once())->method('getBody')
83
+			->will($this->returnValue('{"sitecode":"unittest"}'));
84 84
 
85 85
 
86 86
 		$this->object->run();
87 87
 
88 88
 
89
-		$jobManager = \Aimeos\MAdmin\Factory::createManager( $this->context, 'job' );
89
+		$jobManager = \Aimeos\MAdmin\Factory::createManager($this->context, 'job');
90 90
 		$jobSearch = $jobManager->createSearch();
91
-		$jobSearch->setConditions( $jobSearch->compare( '=~', 'job.label', 'subscription-export_' ) );
92
-		$jobItems = $jobManager->searchItems( $jobSearch );
93
-		$jobManager->deleteItems( array_keys( $jobItems ) );
91
+		$jobSearch->setConditions($jobSearch->compare('=~', 'job.label', 'subscription-export_'));
92
+		$jobItems = $jobManager->searchItems($jobSearch);
93
+		$jobManager->deleteItems(array_keys($jobItems));
94 94
 
95
-		$this->assertEquals( 1, count( $jobItems ) );
95
+		$this->assertEquals(1, count($jobItems));
96 96
 
97 97
 
98
-		$filename = dirname( dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) ) . '/tmp/' . reset( $jobItems )->getLabel();
99
-		$fp = fopen( $filename, 'r' );
98
+		$filename = dirname(dirname(dirname(dirname(dirname(__DIR__))))) . '/tmp/' . reset($jobItems)->getLabel();
99
+		$fp = fopen($filename, 'r');
100 100
 
101
-		$subscription = fgetcsv( $fp );
102
-		$address1 = fgetcsv( $fp );
103
-		$address2 = fgetcsv( $fp );
104
-		$product1 = fgetcsv( $fp );
101
+		$subscription = fgetcsv($fp);
102
+		$address1 = fgetcsv($fp);
103
+		$address2 = fgetcsv($fp);
104
+		$product1 = fgetcsv($fp);
105 105
 
106
-		fclose( $fp );
107
-		unlink( $filename );
106
+		fclose($fp);
107
+		unlink($filename);
108 108
 
109
-		$this->assertEquals( 'subscription', $subscription[0] );
110
-		$this->assertEquals( 'address', $address1[0] );
111
-		$this->assertEquals( 'address', $address2[0] );
112
-		$this->assertEquals( 'product', $product1[0] );
109
+		$this->assertEquals('subscription', $subscription[0]);
110
+		$this->assertEquals('address', $address1[0]);
111
+		$this->assertEquals('address', $address2[0]);
112
+		$this->assertEquals('product', $product1[0]);
113 113
 	}
114 114
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Export/Csv/FactoryTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 		$context = \TestHelperJobs::getContext();
17 17
 		$aimeos = \TestHelperJobs::getAimeos();
18 18
 
19
-		$obj = \Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController( $context, $aimeos );
20
-		$this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj );
19
+		$obj = \Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController($context, $aimeos);
20
+		$this->assertInstanceOf('\\Aimeos\\Controller\\Jobs\\Iface', $obj);
21 21
 	}
22 22
 
23 23
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 		$context = \TestHelperJobs::getContext();
27 27
 		$aimeos = \TestHelperJobs::getAimeos();
28 28
 
29
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
30
-		\Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController( $context, $aimeos, 'Wrong$$$Name' );
29
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
30
+		\Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController($context, $aimeos, 'Wrong$$$Name');
31 31
 	}
32 32
 
33 33
 
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 		$context = \TestHelperJobs::getContext();
37 37
 		$aimeos = \TestHelperJobs::getAimeos();
38 38
 
39
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
40
-		\Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController( $context, $aimeos, 'WrongClass' );
39
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
40
+		\Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController($context, $aimeos, 'WrongClass');
41 41
 	}
42 42
 
43 43
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		$context = \TestHelperJobs::getContext();
47 47
 		$aimeos = \TestHelperJobs::getAimeos();
48 48
 
49
-		$this->setExpectedException( '\\Aimeos\\Controller\\Jobs\\Exception' );
50
-		\Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController( $context, $aimeos, 'Factory' );
49
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
50
+		\Aimeos\Controller\Jobs\Subscription\Export\Csv\Factory::createController($context, $aimeos, 'Factory');
51 51
 	}
52 52
 
53 53
 }
Please login to merge, or discard this patch.