HashGetAll.php 735 B

123456789101112131415161718192021222324252627282930313233343536
  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. class HashGetAll extends Command
  13. {
  14. public function getId()
  15. {
  16. return 'HGETALL';
  17. }
  18. public function parseResponse($data)
  19. {
  20. if ($data instanceof \Iterator) {
  21. return new MultiBulkResponseTuple($data);
  22. }
  23. $result = array();
  24. for ($i = 0; $i < count($data); $i++) {
  25. $result[$data[$i]] = $data[++$i];
  26. }
  27. return $result;
  28. }
  29. }