@@ -95,12 +95,14 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $command = Enum::ZRANGE; |
| 97 | 97 | $args = [$key, $star, $stop]; |
| 98 | - if ($withScores) { |
|
| 98 | + if ($withScores) |
|
| 99 | + { |
|
| 99 | 100 | $args[] = 'WITHSCORES'; |
| 100 | 101 | return $this->dispatch(Builder::build($command, $args))->then(function ($value) { |
| 101 | 102 | $len = count($value); |
| 102 | 103 | $ret = []; |
| 103 | - for ($i=0; $i<$len; $i+=2) { |
|
| 104 | + for ($i=0; $i<$len; $i+=2) |
|
| 105 | + { |
|
| 104 | 106 | $ret[$value[$i]] = $value[$i+1]; |
| 105 | 107 | } |
| 106 | 108 | return $ret; |
@@ -144,10 +146,12 @@ discard block |
||
| 144 | 146 | { |
| 145 | 147 | $command = Enum::ZRANGEBYSCORE; |
| 146 | 148 | $args = [$key, $min, $max]; |
| 147 | - if ($withScores === true) { |
|
| 149 | + if ($withScores === true) |
|
| 150 | + { |
|
| 148 | 151 | $args[] = 'WITHSCORES'; |
| 149 | 152 | } |
| 150 | - if ($offset != 0 || $count != 0) { |
|
| 153 | + if ($offset != 0 || $count != 0) |
|
| 154 | + { |
|
| 151 | 155 | $args[] = 'LIMIT'; |
| 152 | 156 | $args[] = $offset; |
| 153 | 157 | $args[] = $count; |
@@ -156,9 +160,11 @@ discard block |
||
| 156 | 160 | |
| 157 | 161 | return $withScores ? $promise->then(function ($value) { |
| 158 | 162 | $len = is_array($value) ? count($value) : 0; |
| 159 | - if ($len > 0) { |
|
| 163 | + if ($len > 0) |
|
| 164 | + { |
|
| 160 | 165 | $ret = []; |
| 161 | - for ($i=0; $i<$len; $i+=2) { |
|
| 166 | + for ($i=0; $i<$len; $i+=2) |
|
| 167 | + { |
|
| 162 | 168 | $ret[$value[$i]] = $value[$i+1]; |
| 163 | 169 | } |
| 164 | 170 | |
@@ -241,15 +247,18 @@ discard block |
||
| 241 | 247 | $command = Enum::ZREVRANGE; |
| 242 | 248 | $args = [$key, $start, $stop]; |
| 243 | 249 | |
| 244 | - if ($withScores === true) { |
|
| 250 | + if ($withScores === true) |
|
| 251 | + { |
|
| 245 | 252 | $args[] = 'WITHSCORES'; |
| 246 | 253 | |
| 247 | 254 | return $this->dispatch(Builder::build($command, $args)) |
| 248 | 255 | ->then(function ($value) { |
| 249 | 256 | $len = is_array($value) ? count($value) : 0; |
| 250 | - if ($len > 0) { |
|
| 257 | + if ($len > 0) |
|
| 258 | + { |
|
| 251 | 259 | $ret = []; |
| 252 | - for ($i=0; $i<$len; $i+=2) { |
|
| 260 | + for ($i=0; $i<$len; $i+=2) |
|
| 261 | + { |
|
| 253 | 262 | $member = $value[$i]; |
| 254 | 263 | $score = $value[$i+1]; |
| 255 | 264 | $ret[$member] = $score; |
@@ -273,10 +282,12 @@ discard block |
||
| 273 | 282 | { |
| 274 | 283 | $command = Enum::ZREVRANGEBYSCORE; |
| 275 | 284 | $args = [$key, $max, $min]; |
| 276 | - if ($withScores === true) { |
|
| 285 | + if ($withScores === true) |
|
| 286 | + { |
|
| 277 | 287 | $args[] = 'WITHSCORES'; |
| 278 | 288 | } |
| 279 | - if ($offset != 0 || $count != 0) { |
|
| 289 | + if ($offset != 0 || $count != 0) |
|
| 290 | + { |
|
| 280 | 291 | $args[] = 'LIMIT'; |
| 281 | 292 | $args[] = $offset; |
| 282 | 293 | $args[] = $count; |
@@ -285,9 +296,11 @@ discard block |
||
| 285 | 296 | |
| 286 | 297 | return $withScores ? $promise->then(function ($value) { |
| 287 | 298 | $len = is_array($value) ? count($value) : 0; |
| 288 | - if ($len > 0) { |
|
| 299 | + if ($len > 0) |
|
| 300 | + { |
|
| 289 | 301 | $ret = []; |
| 290 | - for ($i=0; $i<$len; $i+=2) { |
|
| 302 | + for ($i=0; $i<$len; $i+=2) |
|
| 303 | + { |
|
| 291 | 304 | $ret[$value[$i]] = $value[$i+1]; |
| 292 | 305 | } |
| 293 | 306 | |