Files
myep/src/BusProNet/XmlParser/BookingsParser.php
T

41 lines
1.7 KiB
PHP

<?php
namespace App\BusProNet\XmlParser;
use App\BusProNet\Model\BaseData;
use App\BusProNet\Model\Booking;
use Symfony\Component\DomCrawler\Crawler;
class BookingsParser extends AbstractParser
{
public function parse(Crawler $result): BaseData
{
$bookings = [];
$items = $result->filterXPath('//vorgaenge/vorgang');
if (0 === $items->count()) {
return new BaseData($bookings);
}
$items->each(function (Crawler $node) use (&$bookings) {
$booking = new Booking();
$booking->id = $this->getIntOrNullValue($node->filterXPath('//id'));
$booking->bookingNumber = $this->getIntOrNullValue($node->filterXPath('//vorgangsnummer'));
$booking->status = $this->getStringOrNullValue($node->filterXPath('//status'));
$booking->participantCount = $this->getIntOrNullValue($node->filterXPath('//personen'));
$booking->price = $this->getFloatOrNullValue($node->filterXPath('//preis'));
$booking->bookingDate = $this->getDateTimeOrNullValue($node->filterXPath('//buchungsdatum'));
$booking->travel = $this->getStringOrNullValue($node->filterXPath('//reise'));
$booking->travelId = $this->getIntOrNullValue($node->filterXPath('//idreise'));
$booking->travelDate = $this->getDateOrNullValue($node->filterXPath('//reisedatum'));
$booking->hasDocuments = $this->getBoolValue($node->filterXPath('//reisedokument'));
$booking->payment = $this->getFloatOrNullValue($node->filterXPath('//zahlung'));
$booking->hasDocuments = $this->getBoolValue($node->filterXPath('//reisedokument'));
$bookings[] = $booking;
});
return new BaseData($bookings);
}
}