fix: restore room occupancy lost to case-sensitive xml attribute lookup

This commit is contained in:
Björn Fromme committed 2026-08-31 14:15:21 +02:00
1 parent 24df764efb
commit e14d29f7d4
10 files changed
+223 -16

No files matched your search

+21 -10
View File
@@ -9,15 +9,6 @@ abstract class AbstractParser
{
use TypeConversionTrait;
protected function getIntOrNullAttribute(?string $value): ?int
{
if (null === $value || '' === $value) {
return null;
}
return (int) $value;
}
protected function getStringOrNullValue(Crawler $node): ?string
{
return 0 < $node->count() ? $node->text() : null;
@@ -64,7 +55,27 @@ abstract class AbstractParser
return null;
}
return $node->attr($attribute);
$value = $node->attr($attribute);
if (null !== $value) {
return $value;
}
// BusPro mixes casing (MinPax in the travel export, minpax in booking
// responses) and addXmlContent() makes attr() case-sensitive.
foreach ($node->getNode(0)->attributes ?? [] as $candidate) {
if (0 === strcasecmp($candidate->name, $attribute)) {
return $candidate->value;
}
}
return null;
}
protected function getIntAttrOrNullValue(Crawler $node, string $attribute): ?int
{
$value = $this->getAttrOrNullValue($node, $attribute);
return null !== $value && '' !== $value ? (int) $value : null;
}
protected function getRequiredAttrValue(Crawler $node, string $attribute, string $context): string
+2 -2
View File
@@ -381,8 +381,8 @@ class TravelParser extends AbstractParser
$room->category = $this->getAttrOrNullValue($roomNode, 'kat');
$room->boardId = (int) $this->getAttrOrNullValue($roomNode, 'idbuspro_vp');
$room->label = $this->getAttrOrNullValue($roomNode, 'zimmertext');
$room->minPax = (int) $this->getAttrOrNullValue($roomNode, 'minpax');
$room->maxPax = (int) $this->getAttrOrNullValue($roomNode, 'maxpax');
$room->minPax = $this->getIntAttrOrNullValue($roomNode, 'minpax');
$room->maxPax = $this->getIntAttrOrNullValue($roomNode, 'maxpax');
$room->nights = (int) $this->getAttrOrNullValue($roomNode, 'naechte');
$roomPrice = $this->getAttrOrNullValue($roomNode, 'preis');
$room->price = null !== $roomPrice && '' !== $roomPrice