ServerConfig.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. * This file is part of the Predis package.
  4. *
  5. * (c) Daniele Alessandri <suppakilla@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Predis\Commands;
  11. use Predis\Iterators\MultiBulkResponseTuple;
  12. /**
  13. * @link http://redis.io/commands/config-set
  14. * @link http://redis.io/commands/config-get
  15. * @link http://redis.io/commands/config-resetstat
  16. * @author Daniele Alessandri <suppakilla@gmail.com>
  17. */
  18. class ServerConfig extends Command
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function getId()
  24. {
  25. return 'CONFIG';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. protected function canBeHashed()
  31. {
  32. return false;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function parseResponse($data)
  38. {
  39. if ($data instanceof \Iterator) {
  40. return new MultiBulkResponseTuple($data);
  41. }
  42. if (is_array($data)) {
  43. $result = array();
  44. for ($i = 0; $i < count($data); $i++) {
  45. $result[$data[$i]] = $data[++$i];
  46. }
  47. return $result;
  48. }
  49. return $data;
  50. }
  51. }