| @@ -6,5 +6,8 @@ | ||
| 6 | 6 | |
| 7 | 7 | interface DriverInterface | 
| 8 | 8 |  { | 
| 9 | + /** | |
| 10 | + * @return string | |
| 11 | + */ | |
| 9 | 12 | public function commands(Request $request); | 
| 10 | 13 | } | 
| 11 | 14 | \ No newline at end of file | 
| @@ -5,4 +5,5 @@ | ||
| 5 | 5 | use Clue\Redis\Protocol\Model\ModelInterface as ClueModelInterface; | 
| 6 | 6 | |
| 7 | 7 | interface RequestInterface extends ClueModelInterface | 
| 8 | -{} | |
| 8 | +{ | |
| 9 | +} | |
| @@ -162,7 +162,7 @@ | ||
| 162 | 162 | |
| 163 | 163 | $this->reqs = []; | 
| 164 | 164 | |
| 165 | - // TODO patch missing pub/sub, pipeline, auth | |
| 165 | + // TODO patch missing pub/sub, pipeline, auth | |
| 166 | 166 | $this->handleStop(); | 
| 167 | 167 |          $this->emit('stop', [ $this ]); | 
| 168 | 168 | |
| @@ -143,7 +143,7 @@ discard block | ||
| 143 | 143 | |
| 144 | 144 | // TODO patch missing pub/sub, pipeline, auth | 
| 145 | 145 | $this->handleStart(); | 
| 146 | -        $this->emit('start', [ $this ]); | |
| 146 | +        $this->emit('start', [$this]); | |
| 147 | 147 | |
| 148 | 148 | return true; | 
| 149 | 149 | } | 
| @@ -174,7 +174,7 @@ discard block | ||
| 174 | 174 | |
| 175 | 175 | // TODO patch missing pub/sub, pipeline, auth | 
| 176 | 176 | $this->handleStop(); | 
| 177 | -        $this->emit('stop', [ $this ]); | |
| 177 | +        $this->emit('stop', [$this]); | |
| 178 | 178 | |
| 179 | 179 | return true; | 
| 180 | 180 | } | 
| @@ -226,8 +226,8 @@ discard block | ||
| 226 | 226 |      { | 
| 227 | 227 | if ($this->stream !== null) | 
| 228 | 228 |          { | 
| 229 | -            $this->stream->on('data', [ $this, 'handleData' ]); | |
| 230 | -            $this->stream->on('close', [ $this, 'stop' ]); | |
| 229 | +            $this->stream->on('data', [$this, 'handleData']); | |
| 230 | +            $this->stream->on('close', [$this, 'stop']); | |
| 231 | 231 | } | 
| 232 | 232 | } | 
| 233 | 233 | |
| @@ -238,8 +238,8 @@ discard block | ||
| 238 | 238 |      { | 
| 239 | 239 | if ($this->stream !== null) | 
| 240 | 240 |          { | 
| 241 | -            $this->stream->removeListener('data', [ $this, 'handleData' ]); | |
| 242 | -            $this->stream->removeListener('close', [ $this, 'stop' ]); | |
| 241 | +            $this->stream->removeListener('data', [$this, 'handleData']); | |
| 242 | +            $this->stream->removeListener('close', [$this, 'stop']); | |
| 243 | 243 | } | 
| 244 | 244 | } | 
| 245 | 245 | |
| @@ -256,7 +256,7 @@ discard block | ||
| 256 | 256 | } | 
| 257 | 257 | catch (ParserException $error) | 
| 258 | 258 |          { | 
| 259 | -            $this->emit('error', [ $this, $error ]); | |
| 259 | +            $this->emit('error', [$this, $error]); | |
| 260 | 260 | $this->stop(); | 
| 261 | 261 | return; | 
| 262 | 262 | } | 
| @@ -269,7 +269,7 @@ discard block | ||
| 269 | 269 | } | 
| 270 | 270 | catch (UnderflowException $error) | 
| 271 | 271 |              { | 
| 272 | -                $this->emit('error', [ $this, $error ]); | |
| 272 | +                $this->emit('error', [$this, $error]); | |
| 273 | 273 | $this->stop(); | 
| 274 | 274 | return; | 
| 275 | 275 | } | 
| @@ -128,9 +128,11 @@ discard block | ||
| 128 | 128 | $stream = $this->createClient($this->endpoint); | 
| 129 | 129 | } | 
| 130 | 130 | catch (Error $ex) | 
| 131 | -        {} | |
| 131 | +        { | |
| 132 | +} | |
| 132 | 133 | catch (Exception $ex) | 
| 133 | -        {} | |
| 134 | +        { | |
| 135 | +} | |
| 134 | 136 | |
| 135 | 137 | if ($ex !== null) | 
| 136 | 138 |          { | 
| @@ -320,9 +322,11 @@ discard block | ||
| 320 | 322 | return new Socket($endpoint, $this->loop); | 
| 321 | 323 | } | 
| 322 | 324 | catch (Error $ex) | 
| 323 | -        {} | |
| 325 | +        { | |
| 326 | +} | |
| 324 | 327 | catch (Exception $ex) | 
| 325 | -        {} | |
| 328 | +        { | |
| 329 | +} | |
| 326 | 330 | |
| 327 | 331 |          throw new ExecutionException('Redis connection socket could not be created!', 0, $ex); | 
| 328 | 332 | } | 
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | * @param string $message | 
| 19 | 19 | * @return mixed | 
| 20 | 20 | */ | 
| 21 | - public function ping($message='pong'); | |
| 21 | + public function ping($message = 'pong'); | |
| 22 | 22 | |
| 23 | 23 | /** | 
| 24 | 24 | * @doc https://redis.io/commands/quit | 
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | * @param array $args | 
| 38 | 38 | * @return mixed | 
| 39 | 39 | */ | 
| 40 | - public function sLowLog($command, array $args=[]); | |
| 40 | + public function sLowLog($command, array $args = []); | |
| 41 | 41 | |
| 42 | 42 | /** | 
| 43 | 43 | * @doc https://redis.io/commands/smembers | 
| @@ -48,13 +48,13 @@ | ||
| 48 | 48 | $command = Enum::HGETALL; | 
| 49 | 49 | $args = [$key]; | 
| 50 | 50 | |
| 51 | -        return $this->dispatch(Builder::build($command, $args))->then(function ($value) { | |
| 51 | +        return $this->dispatch(Builder::build($command, $args))->then(function($value) { | |
| 52 | 52 |              if (!empty($value)) { | 
| 53 | 53 | $tmp = []; | 
| 54 | 54 | $size = count($value); | 
| 55 | -                for ($i=0; $i<$size; $i+=2) { | |
| 55 | +                for ($i = 0; $i < $size; $i += 2) { | |
| 56 | 56 | $field = $value[$i]; | 
| 57 | - $val = $value[$i+1]; | |
| 57 | + $val = $value[$i + 1]; | |
| 58 | 58 | $tmp[$field] = $val; | 
| 59 | 59 | } | 
| 60 | 60 | $value = $tmp; | 
| @@ -49,10 +49,12 @@ discard block | ||
| 49 | 49 | $args = [$key]; | 
| 50 | 50 | |
| 51 | 51 |          return $this->dispatch(Builder::build($command, $args))->then(function ($value) { | 
| 52 | -            if (!empty($value)) { | |
| 52 | + if (!empty($value)) | |
| 53 | +            { | |
| 53 | 54 | $tmp = []; | 
| 54 | 55 | $size = count($value); | 
| 55 | -                for ($i=0; $i<$size; $i+=2) { | |
| 56 | + for ($i=0; $i<$size; $i+=2) | |
| 57 | +                { | |
| 56 | 58 | $field = $value[$i]; | 
| 57 | 59 | $val = $value[$i+1]; | 
| 58 | 60 | $tmp[$field] = $val; | 
| @@ -133,8 +135,10 @@ discard block | ||
| 133 | 135 |      { | 
| 134 | 136 | $command = Enum::HMSET; | 
| 135 | 137 | $args = [$key]; | 
| 136 | -        if (!empty($fvMap)) { | |
| 137 | -            foreach ($fvMap as $field => $value) { | |
| 138 | + if (!empty($fvMap)) | |
| 139 | +        { | |
| 140 | + foreach ($fvMap as $field => $value) | |
| 141 | +            { | |
| 138 | 142 | $tmp[] = $field; | 
| 139 | 143 | $tmp[] = $value; | 
| 140 | 144 | } | 
| @@ -60,7 +60,7 @@ | ||
| 60 | 60 |      { | 
| 61 | 61 | // TODO: Implement geoDist() method. | 
| 62 | 62 | $command = Enum::GEODIST; | 
| 63 | - $args = [$key, $memberA, $memberB ,$unit]; | |
| 63 | + $args = [$key, $memberA, $memberB, $unit]; | |
| 64 | 64 | |
| 65 | 65 | return $this->dispatch(Builder::build($command, $args)); | 
| 66 | 66 | } | 
| @@ -347,7 +347,7 @@ | ||
| 347 | 347 | * @override | 
| 348 | 348 | * @inheritDoc | 
| 349 | 349 | */ | 
| 350 | - public function del($key,...$keys) | |
| 350 | + public function del($key, ...$keys) | |
| 351 | 351 |      { | 
| 352 | 352 | $command = Enum::DEL; | 
| 353 | 353 | $keys[] = $key; | 
| @@ -47,7 +47,8 @@ discard block | ||
| 47 | 47 | $command = Enum::BITFIELD; | 
| 48 | 48 | $subCommand = strtoupper($subCommand); | 
| 49 | 49 | //TODO: control flow improvement | 
| 50 | -        switch ($subCommand) { | |
| 50 | + switch ($subCommand) | |
| 51 | +        { | |
| 51 | 52 |              case 'GET' : { | 
| 52 | 53 | @list ($type, $offset) = $param; | 
| 53 | 54 | $args = [$key, $subCommand, $type, $offset]; | 
| @@ -304,8 +305,10 @@ discard block | ||
| 304 | 305 |      { | 
| 305 | 306 | $command = Enum::MSET; | 
| 306 | 307 | $args = []; | 
| 307 | -        if (!empty($kvMap)) { | |
| 308 | -            foreach ($kvMap as $key => $val) { | |
| 308 | + if (!empty($kvMap)) | |
| 309 | +        { | |
| 310 | + foreach ($kvMap as $key => $val) | |
| 311 | +            { | |
| 309 | 312 | $args[] = $key; | 
| 310 | 313 | $args[] = $val; | 
| 311 | 314 | } | 
| @@ -322,8 +325,10 @@ discard block | ||
| 322 | 325 |      { | 
| 323 | 326 | $command = Enum::MSETNX; | 
| 324 | 327 | $args = []; | 
| 325 | -        if (!empty($kvMap)) { | |
| 326 | -            foreach ($kvMap as $key => $val) { | |
| 328 | + if (!empty($kvMap)) | |
| 329 | +        { | |
| 330 | + foreach ($kvMap as $key => $val) | |
| 331 | +            { | |
| 327 | 332 | $args[] = $key; | 
| 328 | 333 | $args[] = $val; | 
| 329 | 334 | } | 
| @@ -63,7 +63,7 @@ discard block | ||
| 63 | 63 |      { | 
| 64 | 64 | // TODO: Implement sIsMember() method. | 
| 65 | 65 | $command = Enum::SISMEMBER; | 
| 66 | - $args = [$key ,$member]; | |
| 66 | + $args = [$key, $member]; | |
| 67 | 67 | |
| 68 | 68 | return $this->dispatch(Builder::build($command, $args)); | 
| 69 | 69 | } | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 |      { | 
| 77 | 77 | // TODO: Implement sLowLog() method. | 
| 78 | 78 | $command = Enum::SLOWLOG; | 
| 79 | - $args = array_merge([$command],$args); | |
| 79 | + $args = array_merge([$command], $args); | |
| 80 | 80 | |
| 81 | 81 | return $this->dispatch(Builder::build($command, $args)); | 
| 82 | 82 | } | 
| @@ -103,7 +103,7 @@ discard block | ||
| 103 | 103 | // TODO: Implement sMove() method. | 
| 104 | 104 | $command = Enum::SMOVE; | 
| 105 | 105 | $args = [$src, $dst]; | 
| 106 | - $args = array_merge( $args, $members); | |
| 106 | + $args = array_merge($args, $members); | |
| 107 | 107 | |
| 108 | 108 | return $this->dispatch(Builder::build($command, $args)); | 
| 109 | 109 | } |