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

29 lines
878 B
PHP

<?php
declare(strict_types=1);
namespace App\BusProNet\XmlParser;
use App\BusProNet\Model\RegistrationResponse;
use Symfony\Component\DomCrawler\Crawler;
class ContactFormResponseParser extends AbstractParser
{
public function parse(Crawler $node): RegistrationResponse
{
$addressId = $this->getIntOrNullValue($node->filterXPath('//idadresse'));
$personId = $this->getIntOrNullValue($node->filterXPath('//idperson'));
if (null === $addressId || null === $personId) {
throw new \InvalidArgumentException('Missing required idadresse or idperson in contact form response.');
}
$isNewRecord = $this->getBoolValue($node->filterXPath('//neuanlage'));
return new RegistrationResponse(
addressId: $addressId,
personId: $personId,
isNewRecord: $isNewRecord,
);
}
}