@@ -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(); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return $this |
52 | 52 | */ |
53 | 53 | public function on($event, $fn) { |
54 | - if(!array_key_exists($event, $this->listeners)) { |
|
54 | + if (!array_key_exists($event, $this->listeners)) { |
|
55 | 55 | $this->listeners[$event] = array(); |
56 | 56 | } |
57 | 57 | $this->listeners[$event][] = $fn; |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | public function run() { |
66 | 66 | $services = $this->attributeRepository->fetchServices(); |
67 | 67 | $count = 0; |
68 | - foreach($services as $service) { |
|
69 | - if(!array_key_exists($service, $this->services)) { |
|
68 | + foreach ($services as $service) { |
|
69 | + if (!array_key_exists($service, $this->services)) { |
|
70 | 70 | continue; |
71 | 71 | } |
72 | - if(array_key_exists($service, $this->standardTimeouts)) { |
|
72 | + if (array_key_exists($service, $this->standardTimeouts)) { |
|
73 | 73 | $standardTimeout = $this->standardTimeouts[$service]; |
74 | 74 | } else { |
75 | 75 | $standardTimeout = 0; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | try { |
82 | 82 | $this->fireEvent('service-start', $eventParams); |
83 | 83 | $this->attributeRepository->markTry($service); |
84 | - if($this->methodInvoker !== null) { |
|
84 | + if ($this->methodInvoker !== null) { |
|
85 | 85 | $this->methodInvoker->invoke($this->services[$service], $eventParams); |
86 | 86 | } else { |
87 | 87 | call_user_func($this->services[$service], $service); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } catch (\Exception $e) { |
93 | 93 | $eventParams['exception'] = $e; |
94 | 94 | $this->fireEvent('service-failure', $eventParams); |
95 | - if($this->logger !== null) { |
|
95 | + if ($this->logger !== null) { |
|
96 | 96 | $this->logger->critical("{$service}: {$e->getMessage()}", array('exception' => $e)); |
97 | 97 | } else { |
98 | 98 | throw new Exception("{$service}: {$e->getMessage()}", $e->getCode(), $e); |
@@ -107,14 +107,14 @@ discard block |
||
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 | } |
@@ -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 | /** |
@@ -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 = []; |
14 | - foreach($interval as $intervalStr) { |
|
14 | + foreach ($interval as $intervalStr) { |
|
15 | 15 | $result[] = self::parseString($intervalStr); |
16 | 16 | } |
17 | 17 | return min($result); |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * @return int |
26 | 26 | */ |
27 | 27 | private static function parseString($interval) { |
28 | - if(preg_match('/^\\d+$/', $interval)) { |
|
28 | + if (preg_match('/^\\d+$/', $interval)) { |
|
29 | 29 | return $interval; |
30 | 30 | } |
31 | - if(preg_match('/^(\\d{1,2}|\\*):(\\d{1,2}|\\*)(?::(\\d{1,2}|\\*))?$/', $interval, $matches)) { |
|
31 | + if (preg_match('/^(\\d{1,2}|\\*):(\\d{1,2}|\\*)(?::(\\d{1,2}|\\*))?$/', $interval, $matches)) { |
|
32 | 32 | $matches[] = 0; |
33 | 33 | list($hours, $minutes, $seconds) = array_slice($matches, 1); |
34 | 34 | $possibleDates = [ |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @throws Exception |
46 | 46 | */ |
47 | 47 | private static function nearst(array $possibleDates) { |
48 | - foreach($possibleDates as $possibleDate) { |
|
48 | + foreach ($possibleDates as $possibleDate) { |
|
49 | 49 | $time = strtotime($possibleDate); |
50 | - if($time > time()) { |
|
50 | + if ($time > time()) { |
|
51 | 51 | return $time - time(); |
52 | 52 | } |
53 | 53 | } |
@@ -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(); |