31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\BusProNet\XmlParser;
|
|
|
|
use App\BusProNet\Model\PurchaseVoucher;
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
|
|
final class PurchaseVoucherParser extends AbstractParser
|
|
{
|
|
public function parse(Crawler $node): PurchaseVoucher
|
|
{
|
|
$voucherNode = $node->filterXPath('//gutschein');
|
|
|
|
$voucherNumber = $this->getStringOrNullValue($voucherNode->filterXPath('//gutscheinnnr')) ?? '';
|
|
$redemptionCode = $this->getStringOrNullValue($voucherNode->filterXPath('//einloesecode')) ?? '';
|
|
$voucherId = $this->getIntOrNullValue($voucherNode->filterXPath('//idgutschein')) ?? 0;
|
|
$remainingBalance = $this->getFloatOrNullValue($voucherNode->filterXPath('//betrag')) ?? 0.0;
|
|
$type = $this->getStringOrNullValue($voucherNode->filterXPath('//art')) ?? '';
|
|
|
|
return new PurchaseVoucher(
|
|
voucherNumber: $voucherNumber,
|
|
redemptionCode: $redemptionCode,
|
|
voucherId: $voucherId,
|
|
remainingBalance: $remainingBalance,
|
|
type: $type
|
|
);
|
|
}
|
|
}
|