Completed
Push — master ( 3055fa...757c25 )
by Ron
02:11 queued 53s
created
src/Common/IntervalParser.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
 	 * @return int
10 10
 	 */
11 11
 	public static function parse($interval) {
12
-		if(is_array($interval)) {
12
+		if (is_array($interval)) {
13 13
 			$result = array();
14
-			foreach($interval as $intervalStr) {
14
+			foreach ($interval as $intervalStr) {
15 15
 				$result[] = self::parseString($intervalStr);
16 16
 			}
17 17
 			return min($result);
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	 * @throws Exception
27 27
 	 */
28 28
 	private static function parseString($interval) {
29
-		if(preg_match('/^\\d+$/', $interval)) {
29
+		if (preg_match('/^\\d+$/', $interval)) {
30 30
 			return $interval;
31 31
 		}
32
-		if(preg_match('/^(\\d{1,2}|\\*):(\\d{1,2}|\\*)(?::(\\d{1,2}|\\*))?$/', $interval, $matches)) {
32
+		if (preg_match('/^(\\d{1,2}|\\*):(\\d{1,2}|\\*)(?::(\\d{1,2}|\\*))?$/', $interval, $matches)) {
33 33
 			$matches[] = 0;
34 34
 			list($hours, $minutes, $seconds) = array_slice($matches, 1);
35 35
 			$possibleDates = array(
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 	 * @throws Exception
48 48
 	 */
49 49
 	private static function nearst(array $possibleDates) {
50
-		foreach($possibleDates as $possibleDate) {
50
+		foreach ($possibleDates as $possibleDate) {
51 51
 			$time = strtotime($possibleDate);
52
-			if($time > time()) {
52
+			if ($time > time()) {
53 53
 				return $time - time();
54 54
 			}
55 55
 		}
Please login to merge, or discard this patch.
src/AttributeRepositories/MySQLAttributeRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function store($key, $timeout, array $data = []) {
64 64
 		$key = trim(strtolower($key));
65
-		if(!in_array($key, $this->services)) {
65
+		if (!in_array($key, $this->services)) {
66 66
 			$this->services[] = $key;
67 67
 		} else {
68 68
 			throw new RuntimeException("Duplicate service: {$key}");
69 69
 		}
70 70
 
71
-		if($this->has($key)) {
71
+		if ($this->has($key)) {
72 72
 			$this->updateService->execute(['key' => $key, 'timeout' => $timeout]);
73 73
 		} else {
74 74
 			$this->insertService->execute(['key' => $key, 'timeout' => $timeout, 'try' => '2000-01-01 00:00:00', 'run' => '2000-01-01 00:00:00']);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		$this->pdo->exec('START TRANSACTION');
88 88
 		try {
89 89
 			$services = $this->fetchServices();
90
-			foreach($services as $service) {
90
+			foreach ($services as $service) {
91 91
 				$this->updateTryDate->execute(['key' => $service['service_key']]);
92 92
 				$fn($service);
93 93
 				$this->updateRunDate->execute(['key' => $service['service_key']]);
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			}
96 96
 			$this->pdo->exec('COMMIT');
97 97
 			return $count;
98
-		} catch(Throwable $e) {
98
+		} catch (Throwable $e) {
99 99
 			$this->pdo->exec('ROLLBACK');
100 100
 			throw $e;
101 101
 		}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		$this->selectServices->execute();
109 109
 		try {
110 110
 			$services = $this->selectServices->fetchAll(PDO::FETCH_ASSOC);
111
-			foreach($services as $service) {
111
+			foreach ($services as $service) {
112 112
 				yield new Service($service['service_key']);
113 113
 			}
114 114
 		} finally {
Please login to merge, or discard this patch.
src/AttributeRepositories/SqliteAttributeRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function store($key, $timeout, array $data = []) {
67 67
 		$key = trim(strtolower($key));
68
-		if(!in_array($key, $this->services)) {
68
+		if (!in_array($key, $this->services)) {
69 69
 			$this->services[] = $key;
70 70
 		} else {
71 71
 			throw new RuntimeException("Duplicate service: {$key}");
72 72
 		}
73 73
 
74
-		if($this->has($key)) {
74
+		if ($this->has($key)) {
75 75
 			$this->updateService->execute(['key' => $key, 'timeout' => $timeout]);
76 76
 		} else {
77 77
 			$this->insertService->execute(['key' => $key, 'timeout' => $timeout, 'try' => '2000-01-01 00:00:00', 'run' => '2000-01-01 00:00:00']);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		$this->pdo->exec('BEGIN EXCLUSIVE TRANSACTION');
91 91
 		try {
92 92
 			$services = $this->fetchServices();
93
-			foreach($services as $service) {
93
+			foreach ($services as $service) {
94 94
 				$this->updateTryDate->execute(['key' => $service->getKey()]);
95 95
 				$fn($service);
96 96
 				$this->updateRunDate->execute(['key' => $service->getKey()]);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			}
99 99
 			$this->pdo->exec('COMMIT');
100 100
 			return $count;
101
-		} catch(Throwable $e) {
101
+		} catch (Throwable $e) {
102 102
 			$this->pdo->exec('ROLLBACK');
103 103
 			throw $e;
104 104
 		}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$this->selectServices->execute();
112 112
 		try {
113 113
 			$services = $this->selectServices->fetchAll(PDO::FETCH_ASSOC);
114
-			foreach($services as $service) {
114
+			foreach ($services as $service) {
115 115
 				yield new Service($service['service_key']);
116 116
 			}
117 117
 		} finally {
Please login to merge, or discard this patch.
src/Dispatchers/DefaultDispatcher.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return $this
57 57
 	 */
58 58
 	public function on($event, $fn) {
59
-		if(!array_key_exists($event, $this->listeners)) {
59
+		if (!array_key_exists($event, $this->listeners)) {
60 60
 			$this->listeners[$event] = array();
61 61
 		}
62 62
 		$this->listeners[$event][] = $fn;
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 	 * @return int Number of successfully executed services
68 68
 	 */
69 69
 	public function run() {
70
-		return $this->attributeRepository->lockAndIterateServices(function (Service $service) {
71
-			if(!array_key_exists($service->getKey(), $this->services)) {
70
+		return $this->attributeRepository->lockAndIterateServices(function(Service $service) {
71
+			if (!array_key_exists($service->getKey(), $this->services)) {
72 72
 				return;
73 73
 			}
74
-			if(array_key_exists($service->getKey(), $this->standardTimeouts)) {
74
+			if (array_key_exists($service->getKey(), $this->standardTimeouts)) {
75 75
 				$standardTimeout = $this->standardTimeouts[$service->getKey()];
76 76
 			} else {
77 77
 				$standardTimeout = 0;
@@ -82,18 +82,18 @@  discard block
 block discarded – undo
82 82
 			];
83 83
 			try {
84 84
 				$this->fireEvent('service-start', $eventParams);
85
-				if($this->methodInvoker !== null) {
85
+				if ($this->methodInvoker !== null) {
86 86
 					$result = $this->methodInvoker->invoke($this->services[$service->getKey()], $eventParams);
87 87
 				} else {
88 88
 					$result = call_user_func($this->services[$service->getKey()], $service);
89 89
 				}
90
-				if($result !== false) {
90
+				if ($result !== false) {
91 91
 					$this->fireEvent('service-success', $eventParams);
92 92
 				}
93 93
 			} catch (Throwable $e) {
94 94
 				$eventParams['exception'] = $e;
95 95
 				$this->fireEvent('service-failure', $eventParams);
96
-				if($this->logger !== null) {
96
+				if ($this->logger !== null) {
97 97
 					$this->logger->critical("{$service}: {$e->getMessage()}", ['exception' => $e]);
98 98
 				} else {
99 99
 					throw new RuntimeException("{$service}: {$e->getMessage()}", (int) $e->getCode(), $e);
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 	 * @param array $params
108 108
 	 */
109 109
 	private function fireEvent($event, $params) {
110
-		if(array_key_exists($event, $this->listeners)) {
110
+		if (array_key_exists($event, $this->listeners)) {
111 111
 			try {
112
-				foreach($this->listeners[$event] as $listener) {
112
+				foreach ($this->listeners[$event] as $listener) {
113 113
 					$this->methodInvoker->invoke($listener, $params);
114 114
 				}
115 115
 			} catch (Exception $e) {
116 116
 				// Supress exceptions emitted by events
117
-				if($this->logger !== null) {
117
+				if ($this->logger !== null) {
118 118
 					$this->logger->critical($e->getMessage(), array('exception' => $e));
119 119
 				}
120 120
 			}
Please login to merge, or discard this patch.