@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $this->driver = new Credis_Client($host, $port, $timeout, $persistent); |
135 | 135 | $this->driver->setMaxConnectRetries($maxRetries); |
136 | - if ($password){ |
|
136 | + if ($password) { |
|
137 | 137 | $this->driver->auth($password); |
138 | 138 | } |
139 | 139 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $this->driver->select($database); |
149 | 149 | } |
150 | 150 | } |
151 | - catch(CredisException $e) { |
|
151 | + catch (CredisException $e) { |
|
152 | 152 | throw new Resque_RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e); |
153 | 153 | } |
154 | 154 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | // Use a sensible default for an empty DNS string |
174 | 174 | $dsn = 'redis://' . self::DEFAULT_HOST; |
175 | 175 | } |
176 | - if(substr($dsn, 0, 7) === 'unix://') { |
|
176 | + if (substr($dsn, 0, 7) === 'unix://') { |
|
177 | 177 | return array( |
178 | 178 | $dsn, |
179 | 179 | null, |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | |
188 | 188 | // Check the URI scheme |
189 | 189 | $validSchemes = array('redis', 'tcp'); |
190 | - if (isset($parts['scheme']) && ! in_array($parts['scheme'], $validSchemes)) { |
|
190 | + if (isset($parts['scheme']) && !in_array($parts['scheme'], $validSchemes)) { |
|
191 | 191 | throw new \InvalidArgumentException("Invalid DSN. Supported schemes are " . implode(', ', $validSchemes)); |
192 | 192 | } |
193 | 193 | |
194 | 194 | // Allow simple 'hostname' format, which `parse_url` treats as a path, not host. |
195 | - if ( ! isset($parts['host']) && isset($parts['path'])) { |
|
195 | + if (!isset($parts['host']) && isset($parts['path'])) { |
|
196 | 196 | $parts['host'] = $parts['path']; |
197 | 197 | unset($parts['path']); |
198 | 198 | } |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | //check 'password-encoding' parameter and extracting password based on encoding |
221 | - if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'u'){ |
|
221 | + if ($options && isset($options['password-encoding']) && $options['password-encoding'] === 'u') { |
|
222 | 222 | //extracting urlencoded password |
223 | 223 | $pass = isset($parts['pass']) ? urldecode($parts['pass']) : false; |
224 | 224 | } |
225 | - else if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'b'){ |
|
225 | + else if ($options && isset($options['password-encoding']) && $options['password-encoding'] === 'b') { |
|
226 | 226 | //extracting base64 encoded password |
227 | 227 | $pass = isset($parts['pass']) ? base64_decode($parts['pass']) : false; |
228 | 228 | } |
229 | - else{ |
|
229 | + else { |
|
230 | 230 | //extracting pass directly since 'password-encoding' parameter is not present |
231 | 231 | $pass = isset($parts['pass']) ? $parts['pass'] : false; |
232 | 232 | } |
@@ -276,10 +276,10 @@ discard block |
||
276 | 276 | |
277 | 277 | public static function removePrefix($string) |
278 | 278 | { |
279 | - $prefix=self::getPrefix(); |
|
279 | + $prefix = self::getPrefix(); |
|
280 | 280 | |
281 | 281 | if (substr($string, 0, strlen($prefix)) == $prefix) { |
282 | - $string = substr($string, strlen($prefix), strlen($string) ); |
|
282 | + $string = substr($string, strlen($prefix), strlen($string)); |
|
283 | 283 | } |
284 | 284 | return $string; |
285 | 285 | } |
@@ -115,14 +115,11 @@ discard block |
||
115 | 115 | try { |
116 | 116 | if (is_object($client)) { |
117 | 117 | $this->driver = $client; |
118 | - } |
|
119 | - elseif (is_object($server)) { |
|
118 | + } elseif (is_object($server)) { |
|
120 | 119 | $this->driver = $server; |
121 | - } |
|
122 | - elseif (is_array($server)) { |
|
120 | + } elseif (is_array($server)) { |
|
123 | 121 | $this->driver = new Credis_Cluster($server); |
124 | - } |
|
125 | - else { |
|
122 | + } else { |
|
126 | 123 | list($host, $port, $dsnDatabase, $user, $password, $options) = self::parseDsn($server); |
127 | 124 | // $user is not used, only $password |
128 | 125 | |
@@ -147,8 +144,7 @@ discard block |
||
147 | 144 | if ($database !== null) { |
148 | 145 | $this->driver->select($database); |
149 | 146 | } |
150 | - } |
|
151 | - catch(CredisException $e) { |
|
147 | + } catch(CredisException $e) { |
|
152 | 148 | throw new Resque_RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e); |
153 | 149 | } |
154 | 150 | } |
@@ -221,12 +217,10 @@ discard block |
||
221 | 217 | if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'u'){ |
222 | 218 | //extracting urlencoded password |
223 | 219 | $pass = isset($parts['pass']) ? urldecode($parts['pass']) : false; |
224 | - } |
|
225 | - else if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'b'){ |
|
220 | + } else if($options && isset($options['password-encoding']) && $options['password-encoding'] === 'b'){ |
|
226 | 221 | //extracting base64 encoded password |
227 | 222 | $pass = isset($parts['pass']) ? base64_decode($parts['pass']) : false; |
228 | - } |
|
229 | - else{ |
|
223 | + } else{ |
|
230 | 224 | //extracting pass directly since 'password-encoding' parameter is not present |
231 | 225 | $pass = isset($parts['pass']) ? $parts['pass'] : false; |
232 | 226 | } |
@@ -256,15 +250,13 @@ discard block |
||
256 | 250 | foreach ($args[0] AS $i => $v) { |
257 | 251 | $args[0][$i] = self::$defaultNamespace . $v; |
258 | 252 | } |
259 | - } |
|
260 | - else { |
|
253 | + } else { |
|
261 | 254 | $args[0] = self::$defaultNamespace . $args[0]; |
262 | 255 | } |
263 | 256 | } |
264 | 257 | try { |
265 | 258 | return $this->driver->__call($name, $args); |
266 | - } |
|
267 | - catch (CredisException $e) { |
|
259 | + } catch (CredisException $e) { |
|
268 | 260 | throw new Resque_RedisException('Error communicating with Redis: ' . $e->getMessage(), 0, $e); |
269 | 261 | } |
270 | 262 | } |