Inheritance: extends Journey
 public function testCreateFromXml()
 {
     $xml = simplexml_load_file(__DIR__ . '/../../../../fixtures/stationboard.xml');
     $date = \DateTime::createFromFormat('Y-m-d', '2012-03-31', new \DateTimeZone('Europe/Zurich'));
     $date->setTimezone(new \DateTimeZone('Europe/Zurich'));
     $date->setTime(0, 0, 0);
     $this->assertEquals($this->getJourney(), StationBoardJourney::createFromXml($xml->STBRes->JourneyList->STBJourney[0], $date));
 }
Beispiel #2
0
 /**
  * @param Entity\Station $station
  * @param string $boardType
  * @param int $maxJourneys
  * @param string $dateTime
  * @param array $transportationTypes
  */
 public function getStationBoard(StationBoardQuery $query)
 {
     // send request
     $response = $this->sendQuery($query);
     // parse result
     $result = simplexml_load_string($response->getContent());
     // since the stationboard always lists all connections starting from now we just use the date
     // and wrap it accordingly if time goes over midnight
     $journeys = array();
     // subtract one minute because SBB also returns results for one minute in the past
     $prevTime = strtotime($query->date->format('H:i')) - 60;
     $date = $query->date;
     if ($result->STBRes->JourneyList->STBJourney) {
         foreach ($result->STBRes->JourneyList->STBJourney as $journey) {
             $curTime = strtotime((string) $journey->MainStop->BasicStop->Dep->Time);
             if ($prevTime > $curTime && $prevTime - $curTime > self::STATIONBOARD_DELAY_FRAME) {
                 // we passed midnight and the time jumped more than the delay frame
                 $date->add(new \DateInterval('P1D'));
             }
             $journeys[] = Entity\Schedule\StationBoardJourney::createFromXml($journey, $date, null);
             $prevTime = $curTime;
         }
     }
     return $journeys;
 }
Beispiel #3
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;
 }