-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathForecastAlert.php
82 lines (73 loc) · 1.93 KB
/
ForecastAlert.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
<?php
/**
* ForecastAlert.php
*/
/**
* ForecastTools: Alert
*
* An alert object represents a severe weather warning issued for the requested
* location by a governmental authority (for a list of which authorities we
* currently support, please see data sources at
* https://developer.forecast.io/docs/v2
*
* @package ForecastTools
* @author Charlie Gorichanaz <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License
* @version 1.0
* @link http://github.com/CNG/ForecastTools
* @example ../example.php
*/
class ForecastAlert
{
private $_alert;
/**
* Create ForecastAlert object
*
* @param object $alert JSON decoded alert from API response
*/
public function __construct($alert)
{
$this->_alert = $alert;
}
/**
* A short text summary of the alert.
*
* @return string|bool alert “title” data or false if none
*/
public function getTitle()
{
$field = 'title';
return empty($this->_alert->$field) ? false : $this->_alert->$field;
}
/**
* The UNIX time (that is, seconds since midnight GMT on 1 Jan 1970) at which
* the alert will cease to be valid.
*
* @return int|bool alert “expires” data or false if none
*/
public function getExpires()
{
$field = 'expires';
return empty($this->_alert->$field) ? false : $this->_alert->$field;
}
/**
* A detailed text description of the alert from appropriate weather service.
*
* @return string|bool alert “description” data or false if none
*/
public function getDescription()
{
$field = 'description';
return empty($this->_alert->$field) ? false : $this->_alert->$field;
}
/**
* An HTTP(S) URI that contains detailed information about the alert.
*
* @return string|bool alert “URI” data or false if none
*/
public function getURI()
{
$field = 'uri';
return empty($this->_alert->$field) ? false : $this->_alert->$field;
}
}