ServerConfig.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\Command;
  11. use Predis\Iterator\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 AbstractCommand
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function getId()
  24. {
  25. return 'CONFIG';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function parseResponse($data)
  31. {
  32. if ($data instanceof \Iterator) {
  33. return new MultiBulkResponseTuple($data);
  34. }
  35. if (is_array($data)) {
  36. $result = array();
  37. for ($i = 0; $i < count($data); $i++) {
  38. $result[$data[$i]] = $data[++$i];
  39. }
  40. return $result;
  41. }
  42. return $data;
  43. }
  44. }