ServerInfoV24x.php 975 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Predis\Commands;
  3. class ServerInfoV24x extends ServerInfo {
  4. public function parseResponse($data) {
  5. $info = array();
  6. $current = null;
  7. $infoLines = explode("\r\n", $data, -1);
  8. foreach ($infoLines as $row) {
  9. if ($row === '') {
  10. continue;
  11. }
  12. if (preg_match('/^# (\w+)$/', $row, $matches)) {
  13. $info[$matches[1]] = array();
  14. $current = &$info[$matches[1]];
  15. continue;
  16. }
  17. list($k, $v) = explode(':', $row);
  18. if (!preg_match('/^db\d+$/', $k)) {
  19. if ($k === 'allocation_stats') {
  20. $current[$k] = $this->parseAllocationStats($v);
  21. continue;
  22. }
  23. $current[$k] = $v;
  24. }
  25. else {
  26. $current[$k] = $this->parseDatabaseStats($v);
  27. }
  28. }
  29. return $info;
  30. }
  31. }