feat: refactoring of xml parsers
This commit is contained in:
1 parent
11f1508640
commit
6730c243f6
49 files changed
+1414
-1235
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user