66 lines
3.1 KiB
PHP
66 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\BusProNet\XmlParser;
|
|
|
|
use App\BusProNet\Model\Address;
|
|
use App\BusProNet\Model\Communication;
|
|
use App\BusProNet\Model\PersonalData;
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
|
|
class PersonalDataParser extends AbstractParser
|
|
{
|
|
public function parse(Crawler $node): PersonalData
|
|
{
|
|
$personalData = new PersonalData();
|
|
|
|
$personalData->addressId = $this->getIntOrNullValue($node->filterXPath('//idadresse'));
|
|
$personalData->personId = $this->getIntOrNullValue($node->filterXPath('//idperson'));
|
|
|
|
$addressDataNode = $node->filterXPath('//adressdaten');
|
|
|
|
$personalData->dateOfBirth = $this->getDateOrNullValue($addressDataNode->filterXPath('//geburtsdatum'));
|
|
$personalData->firstName = $this->getStringOrNullValue($addressDataNode->filterXPath('//vorname'));
|
|
$personalData->name = $this->getStringOrNullValue($addressDataNode->filterXPath('//name'));
|
|
$personalData->salutation = $this->getStringOrNullValue($addressDataNode->filterXPath('//anrede'));
|
|
$personalData->title = $this->getStringOrNullValue($addressDataNode->filterXPath('//titel'));
|
|
$personalData->gender = strtoupper($this->getStringOrNullValue($addressDataNode->filterXPath('//geschlecht')));
|
|
$personalData->nationality = strtoupper($this->getStringOrNullValue($addressDataNode->filterXPath('//nationalitaet')));
|
|
|
|
$personalData->height = $this->getStringOrNullValue($addressDataNode->filterXPath('//sonstiges1'));
|
|
$personalData->weight = $this->getStringOrNullValue($addressDataNode->filterXPath('//sonstiges2'));
|
|
$personalData->shoeSize = $this->getStringOrNullValue($addressDataNode->filterXPath('//sonstiges3'));
|
|
|
|
$addressNode = $addressDataNode->filterXPath('//anschrift');
|
|
|
|
if (0 < $addressNode->count()) {
|
|
$address = new Address();
|
|
$address->street = $this->getStringOrNullValue($addressNode->filterXPath('//strasse'));
|
|
$address->postCode = $this->getStringOrNullValue($addressNode->filterXPath('//plz'));
|
|
$address->city = $this->getStringOrNullValue($addressNode->filterXPath('//ort'));
|
|
$address->country = $this->getStringOrNullValue($addressNode->filterXPath('//land'));
|
|
|
|
$personalData->address = $address;
|
|
}
|
|
|
|
$contactDataNode = $addressDataNode->filterXPath('//kommunikation');
|
|
|
|
if (0 < $contactDataNode->count()) {
|
|
$communication = new Communication();
|
|
$communication->phone = $this->getStringOrNullValue($contactDataNode->filterXPath('//telefonprivat'));
|
|
$communication->mobile = $this->getStringOrNullValue($contactDataNode->filterXPath('//telefonmobil'));
|
|
$communication->email = $this->getStringOrNullValue($contactDataNode->filterXPath('//email'));
|
|
$communication->newsletter = $this->getBoolValue($contactDataNode->filterXPath('//newsletter'));
|
|
|
|
$personalData->communication = $communication;
|
|
}
|
|
|
|
$remarksNode = $addressDataNode->filterXPath('//bemerkung');
|
|
|
|
if (0 < $remarksNode->count()) {
|
|
$personalData->remarks = $remarksNode->text();
|
|
}
|
|
|
|
return $personalData;
|
|
}
|
|
}
|