-
Notifications
You must be signed in to change notification settings - Fork 0
/
Departures.class.php
95 lines (86 loc) · 2.67 KB
/
Departures.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* This is a class which will return the information with the latest departures from a certain station
*
* @package packages/LiveBoard
* @copyright (C) 2012 by iRail vzw/asbl
* @license AGPLv3
* @author Maarten Cautreels <maarten@flatturtle.com>
*/
include_once('DeLijnStopTimesDao.php');
class DeLijnDepartures extends AReader
{
public function __construct($package, $resource, $RESTparameters)
{
parent::__construct($package, $resource, $RESTparameters);
$this->offset = 0;
$this->rowcount = 1024;
}
public static function getParameters()
{
return array("stationidentifier" => "Station Name or ID that can be found in the Stations resource",
"year" => "Year",
"month" => "Month",
"day" => "Day",
"hour" => "Hour",
"minute" => "Minute",
"offset" => "Offset",
"rowcount" => "Rowcount",
);
}
public static function getRequiredParameters()
{
return array("stationidentifier", "year", "month", "day", "hour", "minute");
}
public function setParameter($key, $val)
{
if ($key == "stationidentifier") {
$this->stationidentifier = $val;
} elseif ($key == "year") {
$this->year = $val;
} elseif ($key == "month") {
$this->month = $val;
} elseif ($key == "day") {
$this->day = $val;
} elseif ($key == "hour") {
$this->hour = $val;
} elseif ($key == "minute") {
$this->minute = $val;
} elseif ($key == "offset") {
$this->offset = $val;
} elseif ($key == "rowcount") {
$this->rowcount = $val;
}
}
public function read()
{
$stopTimesDao = new StopTimesDao();
if (is_numeric($this->stationidentifier)) {
return $stopTimesDao->getDeparturesByID(
$this->stationidentifier,
$this->year,
$this->month,
$this->day,
$this->hour,
$this->minute,
$this->offset,
$this->rowcount
);
} else {
return $stopTimesDao->getDeparturesByName(
$this->stationidentifier,
$this->year,
$this->month,
$this->day,
$this->hour,
$this->minute,
$this->offset,
$this->rowcount
);
}
}
public static function getDoc()
{
return "This resource contains the Departures for a certain Station for a certain date and time from De Lijn.";
}
}