feat: harden xml parsing to avoid uncaught errors
This commit is contained in:
@@ -40,10 +40,10 @@ class BookingParser extends AbstractParser
|
||||
|
||||
$travelData = $node->filterXPath('//reise');
|
||||
|
||||
$booking->travelName = $travelData->attr('bezeichnung');
|
||||
$booking->travelName = $this->getAttrOrNullValue($travelData, 'bezeichnung');
|
||||
$booking->dateId = $this->getIntOrNullValue($node->filterXPath('//idreise'));
|
||||
$booking->travelCode = $travelData->attr('code');
|
||||
$booking->travelDate = $this->stringToDate($travelData->attr('termin'));
|
||||
$booking->travelCode = $this->getAttrOrNullValue($travelData, 'code');
|
||||
$booking->travelDate = $this->stringToDate($this->getAttrOrNullValue($travelData, 'termin'));
|
||||
|
||||
$booking->hotelId = $this->getIntOrNullValue($node->filterXPath('//idpartner'));
|
||||
$booking->hotelName = $this->getStringOrNullValue($node->filterXPath('//partner'));
|
||||
@@ -56,17 +56,17 @@ class BookingParser extends AbstractParser
|
||||
$booking->participants = $this->parseParticipants($node->filterXPath('//teilnehmerliste/teilnehmer'));
|
||||
|
||||
$paymentData = $node->filterXPath('//zahlung');
|
||||
$booking->paymentId = (int) $paymentData->attr('idzahlungsart');
|
||||
$booking->paymentLabel = $paymentData->attr('bezeichnung');
|
||||
$booking->paymentType = $paymentData->attr('art');
|
||||
$booking->paymentId = $this->getAttrOrNullValue($paymentData, 'idzahlungsart');
|
||||
$booking->paymentLabel = $this->getAttrOrNullValue($paymentData, 'bezeichnung');
|
||||
$booking->paymentType = $this->getAttrOrNullValue($paymentData, 'art');
|
||||
|
||||
if (0 < $paymentData->children()->count()) {
|
||||
$bankDataNode = $paymentData->children()->first();
|
||||
$bankAccount = new BankAccount();
|
||||
$bankAccount->iban = $bankDataNode->attr('iban');
|
||||
$bankAccount->bic = $bankDataNode->attr('bic');
|
||||
$bankAccount->bankName = $bankDataNode->attr('kreditinstitut');
|
||||
$bankAccount->holder = $bankDataNode->attr('kontoinhaber');
|
||||
$bankAccount->iban = $this->getAttrOrNullValue($bankDataNode, 'iban');
|
||||
$bankAccount->bic = $this->getAttrOrNullValue($bankDataNode, 'bic');
|
||||
$bankAccount->bankName = $this->getAttrOrNullValue($bankDataNode, 'kreditinstitut');
|
||||
$bankAccount->holder = $this->getAttrOrNullValue($bankDataNode, 'kontoinhaber');
|
||||
$booking->bankAccount = $bankAccount;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,12 @@ class BookingParser extends AbstractParser
|
||||
$participants = [];
|
||||
|
||||
$node->each(function (Crawler $node) use (&$participants) {
|
||||
$id = (int) $node->attr('id');
|
||||
$id = (int) ($this->getAttrOrNullValue($node, 'id') ?? 0);
|
||||
|
||||
if ($id <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$participants[$id - 1] = $this->parsePersonalData($node);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user