31 lines
805 B
PHP
31 lines
805 B
PHP
<?php
|
|
|
|
namespace App\BusProNet\XmlParser;
|
|
|
|
use App\BusProNet\Model\BaseData;
|
|
use App\BusProNet\Model\Country;
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
|
|
class CountriesParser
|
|
{
|
|
public function parse(Crawler $result): BaseData
|
|
{
|
|
$countries = [];
|
|
|
|
$result
|
|
->filterXPath('//laender/land')
|
|
->each(function (Crawler $node) use (&$countries) {
|
|
$country = new Country();
|
|
$country->id = (int) $node->attr('id');
|
|
$country->name = $node->attr('bezeichnung');
|
|
$country->token = $node->attr('kuerzel');
|
|
$country->nationality = $node->attr('nationalitaet');
|
|
|
|
$countries[$country->token] = $country;
|
|
})
|
|
;
|
|
|
|
return new BaseData($countries);
|
|
}
|
|
}
|