-
Notifications
You must be signed in to change notification settings - Fork 0
/
Coordinate.php
115 lines (95 loc) · 2.17 KB
/
Coordinate.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
<?php
/**
* This file implements Coordinate.
*
* @author Admin
* @since 2023
*/
include 'Response.php';
include 'Validator.php';
include 'Request.php';
include 'Curl.php';
include 'Constant.php';
/**
* Coordinate Class
*/
class Coordinate extends Curl
{
/**
* [$instance description]
* @var [type]
*/
private static $instance;
/**
* [$request description]
* @var [type]
*/
private $request;
/**
* [$validator description]
* @var [type]
*/
private $validator;
/**
* [$response description]
* @var [type]
*/
private $response;
/**
* [__construct description]
*/
private function __construct()
{
$this->request = new Request();
$this->validator = new Validator();
$this->response = new Response();
}
/**
* Gets the instance.
*
* @return <type> The instance.
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* { function_description }
*
* @return <type> ( description_of_the_return_value )
*/
public function get()
{
$inputs = $this->request->get(['address', 'api'])->inputs();
$validated = [
$this->validator->rules($inputs)->check('required', 'address'),
$this->validator->rules($inputs)->check('required', 'api'),
];
if (count(array_unique($validated)) > 1) {
return $this->response->validator($validated);
}
$url = $this->uri($inputs['address']);
$data = $this->url($url)->open()->execute()->close()->results();
return $this->response->success($data);
}
/**
* { function_description }
*
* @param string $address The address
*
* @return bool ( description_of_the_return_value )
*/
public function uri($address = null)
{
return ($address == 'google')
? OSM_URL . $address
: GOOGLE_URL . $address;
}
}
/**
* { item_description }
*/
Coordinate::getInstance()->get();