| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 |      { | 
| 63 | 63 | $this->curl = $curl; | 
| 64 | 64 | $this->kvPrefix = $kvPrefix; | 
| 65 | - $this->sessionTTL = (int)$sessionTTL; | |
| 65 | + $this->sessionTTL = (int) $sessionTTL; | |
| 66 | 66 | //If we cannot connect to Consul on start, we have a problem. | 
| 67 | 67 | $this->createSession(); | 
| 68 | 68 | $this->lastSuccessfullCheck = time(); | 
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 | public function heartbeat() | 
| 100 | 100 |      { | 
| 101 | 101 | //If we have last successfull check recently new, we don't have to do anything | 
| 102 | -        if ($this->lastSuccessfullCheck !== null && time() - $this->lastSuccessfullCheck < $this->sessionTTL / 2 ) { | |
| 102 | +        if ($this->lastSuccessfullCheck !== null && time()-$this->lastSuccessfullCheck < $this->sessionTTL / 2) { | |
| 103 | 103 | return false; | 
| 104 | 104 | } | 
| 105 | 105 | //If session reneval succeedes, update last successfull check. | 
| @@ -116,7 +116,7 @@ discard block | ||
| 116 | 116 |          } catch (RuntimeException $e) { | 
| 117 | 117 | //We could not create new session. We can work for some time in 'detached' mode, | 
| 118 | 118 | //but if our TTL time runs out, we have to throw an exception. | 
| 119 | -            if ($this->lastSuccessfullCheck === null || time() - $this->lastSuccessfullCheck >= $this->sessionTTL) { | |
| 119 | +            if ($this->lastSuccessfullCheck === null || time()-$this->lastSuccessfullCheck >= $this->sessionTTL) { | |
| 120 | 120 | throw $e; | 
| 121 | 121 | } | 
| 122 | 122 | return false; | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 | //Check, if we don't have existing value for the session | 
| 135 | 135 |          $currentValue = $this->curl->performGetRequest('/kv/'.$this->kvPrefix.$this->sessionId); | 
| 136 | 136 |          if (!empty($currentValue['Value'])) { | 
| 137 | - return (int)base64_decode($currentValue['Value']); | |
| 137 | + return (int) base64_decode($currentValue['Value']); | |
| 138 | 138 | } | 
| 139 | 139 | //Lock main key to block concurrent checks | 
| 140 | 140 | $this->lockKey(); | 
| @@ -149,7 +149,7 @@ discard block | ||
| 149 | 149 | } | 
| 150 | 150 | //Release the lock on the main key and return machine ID. | 
| 151 | 151 | $this->releaseKey(); | 
| 152 | - return (int)$machineId; | |
| 152 | + return (int) $machineId; | |
| 153 | 153 | } | 
| 154 | 154 | |
| 155 | 155 | /** | 
| @@ -198,12 +198,12 @@ discard block | ||
| 198 | 198 | |
| 199 | 199 | private function createSession() | 
| 200 | 200 |      { | 
| 201 | - $url ='/session/create'; | |
| 201 | + $url = '/session/create'; | |
| 202 | 202 | //We create new session with given TTL and with lock delay equal to half of TTL. | 
| 203 | 203 | $payload = array( | 
| 204 | 204 | 'TTL' => $this->sessionTTL.'s', | 
| 205 | 205 | "Behavior" => "delete", | 
| 206 | - 'LockDelay' => floor($this->sessionTTL/2).'s', | |
| 206 | + 'LockDelay' => floor($this->sessionTTL / 2).'s', | |
| 207 | 207 | ); | 
| 208 | 208 | $returnData = $this->curl->performPutRequest($url, json_encode($payload)); | 
| 209 | 209 |          if (empty($returnData['ID'])) { |