wip: submit booking to api
This commit is contained in:
1 parent
ee264e88d4
commit
7ea52670b9
34 files changed
+3316
-31
No files matched your search
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\BusProNet\XmlParser;
|
||||
|
||||
use App\BusProNet\Model\Agency;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
final class AgencyParser extends AbstractParser
|
||||
{
|
||||
/**
|
||||
* @return Agency[]
|
||||
*/
|
||||
public function parse(Crawler $node): array
|
||||
{
|
||||
$agencies = [];
|
||||
|
||||
$node->filterXPath('//agenturen/agentur')->each(function (Crawler $agencyNode) use (&$agencies): void {
|
||||
$id = (int) $agencyNode->attr('id');
|
||||
$name = $this->getStringOrNullValue($agencyNode->filterXPath('//name')) ?? '';
|
||||
$code = $this->getStringOrNullValue($agencyNode->filterXPath('//code')) ?? '';
|
||||
$street = $this->getStringOrNullValue($agencyNode->filterXPath('//strasse'));
|
||||
$postCode = $this->getStringOrNullValue($agencyNode->filterXPath('//plz'));
|
||||
$city = $this->getStringOrNullValue($agencyNode->filterXPath('//ort'));
|
||||
$phone = $this->getStringOrNullValue($agencyNode->filterXPath('//telefon'));
|
||||
|
||||
$agencies[] = new Agency(
|
||||
id: $id,
|
||||
name: $name,
|
||||
code: $code,
|
||||
street: $street,
|
||||
postCode: $postCode,
|
||||
city: $city,
|
||||
phone: $phone
|
||||
);
|
||||
});
|
||||
|
||||
return $agencies;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user