@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function store($key, $timeout, array $data = array()) { |
63 | 63 | $key = trim(strtolower($key)); |
64 | - if(!in_array($key, $this->services)) { |
|
64 | + if (!in_array($key, $this->services)) { |
|
65 | 65 | $this->services[] = $key; |
66 | 66 | } else { |
67 | 67 | throw new Exception("Duplicate service: {$key}"); |
68 | 68 | } |
69 | 69 | |
70 | - if($this->has($key)) { |
|
70 | + if ($this->has($key)) { |
|
71 | 71 | $this->updateService->bindValue('key', $key); |
72 | 72 | $this->updateService->bindValue('timeout', $timeout); |
73 | 73 | $this->updateService->execute(); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $this->selectServices->execute(); |
110 | 110 | $services = $this->selectServices->fetchAll(PDO::FETCH_ASSOC); |
111 | 111 | $result = array(); |
112 | - foreach($services as $service) { |
|
112 | + foreach ($services as $service) { |
|
113 | 113 | $result[] = $service['service_key']; |
114 | 114 | } |
115 | 115 | $this->selectServices->closeCursor(); |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $lastRunTime = clone $this->getAttributes()->getLastRunTime(); |
46 | 46 | $lastRunTime->modify("+{$this->interval} seconds"); |
47 | 47 | $lastRunTime->setTimezone(new DateTimeZone('UTC')); |
48 | - return ; |
|
48 | + return; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function store($key, $timeout, array $data = array()) { |
63 | 63 | $key = trim(strtolower($key)); |
64 | - if(!in_array($key, $this->services)) { |
|
64 | + if (!in_array($key, $this->services)) { |
|
65 | 65 | $this->services[] = $key; |
66 | 66 | } else { |
67 | 67 | throw new Exception("Duplicate service: {$key}"); |
68 | 68 | } |
69 | 69 | |
70 | - if($this->has($key)) { |
|
70 | + if ($this->has($key)) { |
|
71 | 71 | $this->updateService->bindValue('key', $key); |
72 | 72 | $this->updateService->bindValue('timeout', $timeout); |
73 | 73 | $this->updateService->execute(); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $this->selectServices->execute(); |
110 | 110 | $services = $this->selectServices->fetchAll(PDO::FETCH_ASSOC); |
111 | 111 | $result = array(); |
112 | - foreach($services as $service) { |
|
112 | + foreach ($services as $service) { |
|
113 | 113 | $result[] = $service['service_key']; |
114 | 114 | } |
115 | 115 | $this->selectServices->closeCursor(); |
@@ -9,9 +9,9 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return $this |
54 | 54 | */ |
55 | 55 | public function on($event, $fn) { |
56 | - if(!array_key_exists($event, $this->listeners)) { |
|
56 | + if (!array_key_exists($event, $this->listeners)) { |
|
57 | 57 | $this->listeners[$event] = array(); |
58 | 58 | } |
59 | 59 | $this->listeners[$event][] = $fn; |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | public function run() { |
68 | 68 | $services = $this->attributeRepository->fetchServices(); |
69 | 69 | $count = 0; |
70 | - foreach($services as $service) { |
|
71 | - if(!array_key_exists($service, $this->services)) { |
|
70 | + foreach ($services as $service) { |
|
71 | + if (!array_key_exists($service, $this->services)) { |
|
72 | 72 | continue; |
73 | 73 | } |
74 | - if(array_key_exists($service, $this->standardTimeouts)) { |
|
74 | + if (array_key_exists($service, $this->standardTimeouts)) { |
|
75 | 75 | $standardTimeout = $this->standardTimeouts[$service]; |
76 | 76 | } else { |
77 | 77 | $standardTimeout = 0; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | try { |
84 | 84 | $this->fireEvent('service-start', $eventParams); |
85 | 85 | $this->attributeRepository->markTry($service); |
86 | - if($this->methodInvoker !== null) { |
|
86 | + if ($this->methodInvoker !== null) { |
|
87 | 87 | $this->methodInvoker->invoke($this->services[$service], $eventParams); |
88 | 88 | } else { |
89 | 89 | call_user_func($this->services[$service], $service); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } catch (\Exception $e) { |
95 | 95 | $eventParams['exception'] = $e; |
96 | 96 | $this->fireEvent('service-failure', $eventParams); |
97 | - if($this->logger !== null) { |
|
97 | + if ($this->logger !== null) { |
|
98 | 98 | $this->logger->critical("{$service}: {$e->getMessage()}", array('exception' => $e)); |
99 | 99 | } else { |
100 | 100 | throw new Exception("{$service}: {$e->getMessage()}", (int) $e->getCode(), $e); |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * @param array $params |
110 | 110 | */ |
111 | 111 | private function fireEvent($event, $params) { |
112 | - if(array_key_exists($event, $this->listeners)) { |
|
112 | + if (array_key_exists($event, $this->listeners)) { |
|
113 | 113 | try { |
114 | - foreach($this->listeners[$event] as $listener) { |
|
114 | + foreach ($this->listeners[$event] as $listener) { |
|
115 | 115 | $this->methodInvoker->invoke($listener, $params); |
116 | 116 | } |
117 | 117 | } catch (Exception $e) { |
118 | 118 | // Supress exceptions emitted by events |
119 | - if($this->logger !== null) { |
|
119 | + if ($this->logger !== null) { |
|
120 | 120 | $this->logger->critical($e->getMessage(), array('exception' => $e)); |
121 | 121 | } |
122 | 122 | } |