|
@@ -34,27 +34,37 @@ class ServerInfo extends AbstractCommand
|
|
|
$infoLines = preg_split('/\r?\n/', $data);
|
|
|
|
|
|
foreach ($infoLines as $row) {
|
|
|
- @list($k, $v) = explode(':', $row);
|
|
|
-
|
|
|
- if ($row === '' || !isset($v)) {
|
|
|
+ if (strpos($row, ':') === false) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (!preg_match('/^db\d+$/', $k)) {
|
|
|
- if ($k === 'allocation_stats') {
|
|
|
- $info[$k] = $this->parseAllocationStats($v);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- $info[$k] = $v;
|
|
|
- } else {
|
|
|
- $info[$k] = $this->parseDatabaseStats($v);
|
|
|
- }
|
|
|
+ list($k, $v) = $this->parseRow($row);
|
|
|
+ $info[$k] = $v;
|
|
|
}
|
|
|
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Parses single row of the reply buffer and returns the key-value pair.
|
|
|
+ *
|
|
|
+ * @param string $row Single row of the reply buffer.
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function parseRow($row)
|
|
|
+ {
|
|
|
+ list($k, $v) = explode(':', $row, 2);
|
|
|
+
|
|
|
+ if (!preg_match('/^db\d+$/', $k)) {
|
|
|
+ if ($k === 'allocation_stats') {
|
|
|
+ $v = $this->parseAllocationStats($v);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $v = $this->parseDatabaseStats($v);
|
|
|
+ }
|
|
|
+ return [$k, $v];
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Parses the reply buffer and extracts the statistics of each logical DB.
|
|
|
*
|