protected function getResponseLines($cmd)
{
$result = null;
$this->write(trim($cmd));
$response = $this->read();
$matches = [];
if (!preg_match('#^(OK (\\d+))#mi', $response, $matches)) {
throw new \RuntimeException(sprintf('Unhandled response: %s', $response));
}
$result = preg_split("#[\r\n]+#", rtrim($this->read($matches[2])));
// discard header line
if (isset($result[0]) && $result[0] == '---') {
array_shift($result);
}
return $result;
}