ServerInfoV26x.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. /**
  12. * @link http://redis.io/commands/info
  13. * @author Daniele Alessandri <suppakilla@gmail.com>
  14. */
  15. class ServerInfoV26x extends ServerInfo
  16. {
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function parseResponse($data)
  21. {
  22. $info = array();
  23. $current = null;
  24. $infoLines = preg_split('/\r?\n/', $data);
  25. if (isset($infoLines[0]) && $infoLines[0][0] !== '#') {
  26. return parent::parseResponse($data);
  27. }
  28. foreach ($infoLines as $row) {
  29. if ($row === '') {
  30. continue;
  31. }
  32. if (preg_match('/^# (\w+)$/', $row, $matches)) {
  33. $info[$matches[1]] = array();
  34. $current = &$info[$matches[1]];
  35. continue;
  36. }
  37. list($k, $v) = $this->parseRow($row);
  38. $current[$k] = $v;
  39. }
  40. return $info;
  41. }
  42. }