Result.class.php
1.32 KB
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
<?php
/**
* User: graymur
* Date: 06.11.13
* Time: 16:11
*/
namespace Cpeople\Classes\Geolocation;
class Result
{
private $_city;
private $_country;
private $_region;
private $_destrict;
private $_latitude;
private $_longtitude;
private $error;
public function __call($funcName, $args)
{
if (preg_match('#^set([a-z]+)$#i', $funcName, $m))
{
$varname = '_' . strtolower($m[1]);
if (!property_exists(__CLASS__, $varname))
{
throw new GeoLocException("Class " . __CLASS__ . " does not have property {$varname}");
}
$this->{$varname} = $args[0];
}
else if (preg_match('#^get([a-z]+)$#i', $funcName, $m))
{
$varname = '_' . strtolower($m[1]);
if (!property_exists(__CLASS__, $varname))
{
throw new GeoLocException("Class " . __CLASS__ . " does not have property {$varname}");
}
return $this->{$varname};
}
}
public function setError($error)
{
$this->error = $error;
}
public function isError()
{
return (bool) $this->error;
}
public function getError()
{
return $this->error;
}
}