Transport\Entity\Schedule\StationBoardJourney::createStationBoardFromXml PHP Méthode

createStationBoardFromXml() public static méthode

public static createStationBoardFromXml ( SimpleXMLElement $xml, DateTime $date, StationBoardJourney $obj = null ) : StationBoardJourney
$xml SimpleXMLElement
$date DateTime The date that will be assigned to this journey
$obj StationBoardJourney An optional existing journey to overwrite
Résultat StationBoardJourney
    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;
    }

Usage Example

Exemple #1
0
 /**
  * @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;
 }
StationBoardJourney