Skip to content

Commit

Permalink
Merge pull request #3 from reyadkhan/master
Browse files Browse the repository at this point in the history
fix: fixed undefined array key 'StopLocation'
  • Loading branch information
Bertware authored Aug 18, 2023
2 parents 174acca + 33b9659 commit 4a746f4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Trafiklab/ResRobot/Internal/ResRobotClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function getTimeTable(string $key, ResRobotTimeTableRequest $request): Ti
"id" => $request->getStopId(),
"date" => $request->getDateTime()->format("Y-m-d"),
"time" => $request->getDateTime()->format("H:i"),
"lang" => $request->getLanguage(),
"format" => "json",
"passlist" => "0",
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ private function parseApiResponse(array $json)
{
$this->_stopLocations = [];
foreach ($json['stopLocationOrCoordLocation'] as $result) {
if( ! isset($result['StopLocation'])) {
continue;
}
$stopLocationJson = $result['StopLocation'];
$this->_stopLocations[] = new ResRobotStopLocationLookupEntry($stopLocationJson);
}
Expand Down
16 changes: 16 additions & 0 deletions src/Trafiklab/ResRobot/Model/ResRobotTimeTableRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ResRobotTimeTableRequest extends ResRobotBaseRequest implements TimeTableR
{
private $_timeTableType = TimeTableType::DEPARTURES;
private $_stopId = "";
private $_lang = "sv";

/**
* @return mixed
Expand Down Expand Up @@ -47,5 +48,20 @@ public function setTimeTableType(int $timeTableType): void
$this->_timeTableType = $timeTableType;
}

/**
* @return string
*/
public function getLanguage(): string
{
return $this->_lang;
}

/**
* @param string $lang
* @return void
*/
public function setLanguage(string $lang): void
{
$this->_lang = $lang;
}
}

0 comments on commit 4a746f4

Please sign in to comment.