feat: promotional and purchase vouchers
This commit is contained in:
1 parent
26681e5c62
commit
aaa7e9f4c3
21 files changed
+847
-6
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<?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
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user