123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace Predis\Command;
- class HashScan extends PrefixableCommand
- {
-
- public function getId()
- {
- return 'HSCAN';
- }
-
- protected function filterArguments(Array $arguments)
- {
- if (count($arguments) === 3 && is_array($arguments[2])) {
- $options = $this->prepareOptions(array_pop($arguments));
- $arguments = array_merge($arguments, $options);
- }
- return $arguments;
- }
-
- protected function prepareOptions($options)
- {
- $options = array_change_key_case($options, CASE_UPPER);
- $normalized = array();
- if (!empty($options['MATCH'])) {
- $normalized[] = 'MATCH';
- $normalized[] = $options['MATCH'];
- }
- if (!empty($options['COUNT'])) {
- $normalized[] = 'COUNT';
- $normalized[] = $options['COUNT'];
- }
- return $normalized;
- }
-
- public function parseResponse($data)
- {
- if (is_array($data)) {
- $data[0] = (int) $data[0];
- $fields = $data[1];
- $result = array();
- for ($i = 0; $i < count($fields); $i++) {
- $result[$fields[$i]] = $fields[++$i];
- }
- $data[1] = $result;
- }
- return $data;
- }
- }
|