Completed
Push — master ( 7313f0...a0f3ba )
by Aimeos
02:53
created
controller/jobs/src/Controller/Jobs/Subscription/Process/End/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/process/end/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/process/end/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\\Process\\End\\' . $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\\Process\\End\\' . $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/process/end/decorators/excludes
83 83
 		 * Excludes decorators added by the "common" option from the subscription process CSV job controller
@@ -154,6 +154,6 @@  discard block
 block discarded – undo
154 154
 		 * @see controller/jobs/subscription/process/end/decorators/excludes
155 155
 		 * @see controller/jobs/subscription/process/end/decorators/global
156 156
 		 */
157
-		return self::addControllerDecorators( $context, $aimeos, $controller, 'subscription/process/end' );
157
+		return self::addControllerDecorators($context, $aimeos, $controller, 'subscription/process/end');
158 158
 	}
159 159
 }
160 160
\ No newline at end of file
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/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,48 +65,48 @@  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
-					$item->setStatus( 0 );
97
-					$manager->saveItem( $item );
96
+					$item->setStatus(0);
97
+					$manager->saveItem($item);
98 98
 				}
99
-				catch( \Exception $e )
99
+				catch (\Exception $e)
100 100
 				{
101 101
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
102
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
103
-					$logger->log( $e->getTraceAsString() );
102
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
103
+					$logger->log($e->getTraceAsString());
104 104
 				}
105 105
 			}
106 106
 
107
-			$count = count( $items );
107
+			$count = count($items);
108 108
 			$start += $count;
109 109
 		}
110
-		while( $count === $search->getSliceSize() );
110
+		while ($count === $search->getSliceSize());
111 111
 	}
112 112
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,8 +95,7 @@
 block discarded – undo
95 95
 
96 96
 					$item->setStatus( 0 );
97 97
 					$manager->saveItem( $item );
98
-				}
99
-				catch( \Exception $e )
98
+				} catch( \Exception $e )
100 99
 				{
101 100
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
102 101
 					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
Please login to merge, or discard this patch.
controller/jobs/src/Controller/Jobs/Subscription/Process/Begin/Standard.php 1 patch
Spacing   +22 added lines, -22 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 start' );
31
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Subscription process start');
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', 'Process subscriptions initially' );
42
+		return $this->getContext()->getI18n()->dt('controller/jobs', 'Process subscriptions initially');
43 43
 	}
44 44
 
45 45
 
@@ -65,50 +65,50 @@  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.datenext', null ),
75
+			$search->compare('==', 'subscription.datenext', null),
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->begin( $item );
92
+					foreach ($processors as $processor) {
93
+						$processor->begin($item);
94 94
 					}
95 95
 
96
-					$interval = \DateInterval::createFromDateString( $item->getInterval() );
97
-					$item->setDateNext( date_create( $item->getTimeCreated() )->add( $interval )->format( 'Y-m-d' ) );
96
+					$interval = \DateInterval::createFromDateString($item->getInterval());
97
+					$item->setDateNext(date_create($item->getTimeCreated())->add($interval)->format('Y-m-d'));
98 98
 
99
-					$manager->saveItem( $item );
99
+					$manager->saveItem($item);
100 100
 				}
101
-				catch( \Exception $e )
101
+				catch (\Exception $e)
102 102
 				{
103 103
 					$msg = 'Unable to process subscription with ID "%1$S": %2$s';
104
-					$logger->log( sprintf( $msg, $item->getId(), $e->getMessage() ) );
105
-					$logger->log( $e->getTraceAsString() );
104
+					$logger->log(sprintf($msg, $item->getId(), $e->getMessage()));
105
+					$logger->log($e->getTraceAsString());
106 106
 				}
107 107
 			}
108 108
 
109
-			$count = count( $items );
109
+			$count = count($items);
110 110
 			$start += $count;
111 111
 		}
112
-		while( $count === $search->getSliceSize() );
112
+		while ($count === $search->getSliceSize());
113 113
 	}
114 114
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Process/End/StandardTest.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -20,30 +20,30 @@  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\End\Standard( $this->context, $aimeos );
23
+		$this->object = new \Aimeos\Controller\Jobs\Subscription\Process\End\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 end', $this->object->getName() );
40
+		$this->assertEquals('Subscription process end', $this->object->getName());
41 41
 	}
42 42
 
43 43
 
44 44
 	public function testGetDescription()
45 45
 	{
46
-		$this->assertEquals( 'Terminates expired subscriptions', $this->object->getDescription() );
46
+		$this->assertEquals('Terminates expired subscriptions', $this->object->getDescription());
47 47
 	}
48 48
 
49 49
 
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 	{
52 52
 		$item = $this->getSubscription();
53 53
 
54
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
55
-			->setConstructorArgs( [$this->context] )
56
-			->setMethods( ['searchItems', 'saveItem'] )
54
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
55
+			->setConstructorArgs([$this->context])
56
+			->setMethods(['searchItems', 'saveItem'])
57 57
 			->getMock();
58 58
 
59
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
59
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
60 60
 
61
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
62
-			->will( $this->returnValue( [$item] ) );
61
+		$managerStub->expects($this->once())->method('searchItems')
62
+			->will($this->returnValue([$item]));
63 63
 
64
-		$managerStub->expects( $this->once() )->method( 'saveItem' );
64
+		$managerStub->expects($this->once())->method('saveItem');
65 65
 
66 66
 		$this->object->run();
67 67
 	}
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
 	{
72 72
 		$item = $this->getSubscription();
73 73
 
74
-		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Subscription\\Manager\\Standard' )
75
-			->setConstructorArgs( [$this->context] )
76
-			->setMethods( ['searchItems', 'saveItem'] )
74
+		$managerStub = $this->getMockBuilder('\\Aimeos\\MShop\\Subscription\\Manager\\Standard')
75
+			->setConstructorArgs([$this->context])
76
+			->setMethods(['searchItems', 'saveItem'])
77 77
 			->getMock();
78 78
 
79
-		\Aimeos\MShop\Factory::injectManager( $this->context, 'subscription', $managerStub );
79
+		\Aimeos\MShop\Factory::injectManager($this->context, 'subscription', $managerStub);
80 80
 
81
-		$managerStub->expects( $this->once() )->method( 'searchItems' )
82
-			->will( $this->returnValue( [$item] ) );
81
+		$managerStub->expects($this->once())->method('searchItems')
82
+			->will($this->returnValue([$item]));
83 83
 
84
-		$managerStub->expects( $this->once() )->method( 'saveItem' )
85
-			->will( $this->throwException( new \Exception() ) );
84
+		$managerStub->expects($this->once())->method('saveItem')
85
+			->will($this->throwException(new \Exception()));
86 86
 
87 87
 		$this->object->run();
88 88
 	}
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
 
91 91
 	protected function getSubscription()
92 92
 	{
93
-		$manager = \Aimeos\MShop\Factory::createManager( $this->context, 'subscription' );
93
+		$manager = \Aimeos\MShop\Factory::createManager($this->context, 'subscription');
94 94
 
95 95
 		$search = $manager->createSearch();
96
-		$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) );
96
+		$search->setConditions($search->compare('==', 'subscription.dateend', '2010-01-01'));
97 97
 
98
-		$items = $manager->searchItems( $search );
98
+		$items = $manager->searchItems($search);
99 99
 
100
-		if( ( $item = reset( $items ) ) !== false ) {
100
+		if (($item = reset($items)) !== false) {
101 101
 			return $item;
102 102
 		}
103 103
 
104
-		throw new \Exception( 'No subscription item found' );
104
+		throw new \Exception('No subscription item found');
105 105
 	}
106 106
 }
Please login to merge, or discard this patch.
jobs/tests/Controller/Jobs/Subscription/Process/End/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\Process\End\Factory::createController( $context, $aimeos );
20
-		$this->assertInstanceOf( '\\Aimeos\\Controller\\Jobs\\Iface', $obj );
19
+		$obj = \Aimeos\Controller\Jobs\Subscription\Process\End\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\Process\End\Factory::createController( $context, $aimeos, 'Wrong$$$Name' );
29
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
30
+		\Aimeos\Controller\Jobs\Subscription\Process\End\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\Process\End\Factory::createController( $context, $aimeos, 'WrongClass' );
39
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
40
+		\Aimeos\Controller\Jobs\Subscription\Process\End\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\Process\End\Factory::createController( $context, $aimeos, 'Factory' );
49
+		$this->setExpectedException('\\Aimeos\\Controller\\Jobs\\Exception');
50
+		\Aimeos\Controller\Jobs\Subscription\Process\End\Factory::createController($context, $aimeos, 'Factory');
51 51
 	}
52 52
 
53 53
 }
Please login to merge, or discard this patch.