protected function getProperties(\GuzzleHttp\Psr7\Response $response) : array
{
// Process the XML with properties
$properties = [];
$reader = new \Jyxo\XmlReader();
$reader->XML((string) $response->getBody());
// Ignore warnings
while (@$reader->read()) {
if (\XMLReader::ELEMENT === $reader->nodeType && 'D:prop' === $reader->name) {
while (@$reader->read()) {
// Element must not be empty and has to look something like <lp1:getcontentlength>13744</lp1:getcontentlength>
if (\XMLReader::ELEMENT === $reader->nodeType && !$reader->isEmptyElement) {
if (preg_match('~^lp\\d+:(.+)$~', $reader->name, $matches)) {
// Apache
$properties[$matches[1]] = $reader->getTextValue();
} elseif (preg_match('~^D:(.+)$~', $reader->name, $matches)) {
// Lighttpd
$properties[$matches[1]] = $reader->getTextValue();
}
} elseif (\XMLReader::END_ELEMENT === $reader->nodeType && 'D:prop' === $reader->name) {
break;
}
}
}
}
return $properties;
}