wip: initial commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\ApiResponseParser;
|
||||
|
||||
use App\BusProNet\Model\BaseData;
|
||||
use App\BusProNet\Model\MutableField;
|
||||
|
||||
class MutableFieldsResponseParser
|
||||
{
|
||||
use ResponseParserTrait;
|
||||
|
||||
public function parse(\SimpleXMLElement $xml): BaseData
|
||||
{
|
||||
$mutableFields = [];
|
||||
|
||||
foreach ($xml->änderungen->änderung as $item) {
|
||||
$attributes = $item->attributes();
|
||||
|
||||
$type = match ((string) $attributes['art']) {
|
||||
'anzahl_teilnehmer' => 'participant_count',
|
||||
'beförderung' => 'transportation',
|
||||
'zustieg' => 'pickup',
|
||||
'unterbringung' => 'accommodation',
|
||||
'zusatzleistung' => 'services',
|
||||
'teilnehmerdaten' => 'participant_data',
|
||||
default => false,
|
||||
};
|
||||
|
||||
if (false === $type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mutableField = new MutableField($type, $this->stringToBool((string) $attributes['möglich']));
|
||||
|
||||
if ($attributes['möglichbiszum']) {
|
||||
$mutableField->mutableBefore = $this->stringToDate((string) $attributes['möglichbiszum']);
|
||||
}
|
||||
|
||||
$mutableFields[$type] = $mutableField;
|
||||
}
|
||||
|
||||
return new BaseData($mutableFields);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user