public static createStationBoardFromXml ( SimpleXMLElement $xml, DateTime $date, |
||
$xml | SimpleXMLElement | |
$date | DateTime | The date that will be assigned to this journey |
$obj | An optional existing journey to overwrite | |
return |
public static function createStationBoardFromXml(\SimpleXMLElement $xml, \DateTime $date, StationBoardJourney $obj = null)
{
if (!$obj) {
$obj = new self();
}
$stop = Stop::createFromXml($xml->MainStop->BasicStop, $date, null);
// use resolved date from main stop
$date = new \DateTime($stop->departure);
/* @var $obj StationBoardJourney */
$obj = Journey::createFromXml($xml, $date, $obj);
$obj->stop = $stop;
return $obj;
}
/** * @return array */ public function getStationBoard(StationBoardQuery $query) { // send request $result = $this->sendAndParseQuery($query); $date = $query->date; $journeys = []; if ($result->STBRes->JourneyList->STBJourney) { foreach ($result->STBRes->JourneyList->STBJourney as $journey) { $journey = Entity\Schedule\StationBoardJourney::createStationBoardFromXml($journey, $date, null); $date = new \DateTime($journey->stop->departure); $journeys[] = $journey; } } return $journeys; }