/
Host.php
121 lines (108 loc) · 2.24 KB
/
Host.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
namespace DavidePastore\Ipinfo;
/**
* Represent an host with all the details.
*
* @author davidepastore
*/
class Host
{
/**
* Contains all the properties of the host.
*
* @var array
*/
protected $properties;
/**
* Create an Host object with all the properties.
*
* @param array $properties
*/
public function __construct($properties = array())
{
//Merge default values
$this->properties = array_merge(array(
Ipinfo::CITY => '',
Ipinfo::COUNTRY => '',
Ipinfo::HOSTNAME => '',
Ipinfo::IP => '',
Ipinfo::LOC => '',
Ipinfo::ORG => '',
Ipinfo::PHONE => '',
Ipinfo::POSTAL => '',
Ipinfo::REGION => '',
), $properties);
}
/**
* Get the city value.
*/
public function getCity()
{
return $this->properties[Ipinfo::CITY];
}
/**
* Get the country value.
*/
public function getCountry()
{
return $this->properties[Ipinfo::COUNTRY];
}
/**
* Get the hostname value.
*/
public function getHostname()
{
return $this->properties[Ipinfo::HOSTNAME];
}
/**
* Get the ip value.
*/
public function getIp()
{
return $this->properties[Ipinfo::IP];
}
/**
* Get the loc value.
*/
public function getLoc()
{
return $this->properties[Ipinfo::LOC];
}
/**
* Get the org value.
*/
public function getOrg()
{
return $this->properties[Ipinfo::ORG];
}
/**
* Get the phone value.
*/
public function getPhone()
{
return $this->properties[Ipinfo::PHONE];
}
/**
* Get the postal value.
*/
public function getPostal()
{
return $this->properties[Ipinfo::POSTAL];
}
/**
* Get the region value.
*/
public function getRegion()
{
return $this->properties[Ipinfo::REGION];
}
/**
* Get all the properties.
*
* @return array An associative array with all the properties.
*/
public function getProperties()
{
return $this->properties;
}
}