Completed
Push — master ( fa09b4...cd114b )
by Bradley
02:58
created

Location::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Cornford\Googlmapper\Models;
2
3
use Cornford\Googlmapper\Contracts\ModelingInterface;
4
use Cornford\Googlmapper\Contracts\ObjectableInterface;
5
use Cornford\Googlmapper\Mapper;
6
use Illuminate\View\Factory as View;
7
8
class Location implements ObjectableInterface {
9
10
	/**
11
	 * Mapper instance.
12
	 *
13
	 * @var Mapper
14
	 */
15
	protected static $mapper;
16
17
	/**
18
	 * Search.
19
	 *
20
	 * @var string
21
	 */
22
	protected $search;
23
24
	/**
25
	 * Address.
26
	 *
27
	 * @var string
28
	 */
29
	protected $address;
30
31
	/**
32
	 * Type.
33
	 *
34
	 * @var string
35
	 */
36
	protected $type;
37
38
	/**
39
	 * Latitude.
40
	 *
41
	 * @var float
42
	 */
43
	protected $latitude;
44
45
	/**
46
	 * Longitude.
47
	 *
48
	 * @var float
49
	 */
50
	protected $longitude;
51
52
	/**
53
	 * Place Id.
54
	 *
55
	 * @var string
56
	 */
57
	protected $placeId;
58
59
	/**
60
	 * Public constructor.
61
	 *
62
	 * @param array $parameters
63
	 */
64
	public function __construct(array $parameters = [])
65
	{
66
		$this->setMapper($parameters['mapper']);
67
		$this->setSearch($parameters['search']);
68
		$this->setAddress($parameters['address']);
69
		$this->setType($parameters['type']);
70
		$this->setLatitude($parameters['latitude']);
71
		$this->setLongitude($parameters['longitude']);
72
		$this->setPlaceId($parameters['placeId']);
73
	}
74
75
	/**
76
	 * Get the mapper instance.
77
	 *
78
	 * @return Mapper
79
	 */
80
	protected function getMapper()
81
	{
82
		return self::$mapper;
83
	}
84
85
	/**
86
	 * Set the mapper instance.
87
	 *
88
	 * @param Mapper $mapper
89
	 *
90
	 * @return void
91
	 */
92
	protected function setMapper(Mapper $mapper)
93
	{
94
		self::$mapper = $mapper;
95
	}
96
97
	/**
98
	 * Get the locations search.
99
	 *
100
	 * @return string
101
	 */
102
	public function getSearch()
103
	{
104
		return $this->search;
105
	}
106
107
	/**
108
	 * Set the locations search.
109
	 *
110
	 * @param string $search
111
	 *
112
	 * @return void
113
	 */
114
	protected function setSearch($search)
115
	{
116
		$this->search = $search;
117
	}
118
119
	/**
120
	 * Get the locations address.
121
	 *
122
	 * @return string
123
	 */
124
	public function getAddress()
125
	{
126
		return $this->address;
127
	}
128
129
	/**
130
	 * Set the locations address.
131
	 *
132
	 * @param string $address
133
	 *
134
	 * @return void
135
	 */
136
	protected function setAddress($address)
137
	{
138
		$this->address = $address;
139
	}
140
141
	/**
142
	 * Get the locations type.
143
	 *
144
	 * @return string
145
	 */
146
	public function getType()
147
	{
148
		return $this->type;
149
	}
150
151
	/**
152
	 * Set the locations type.
153
	 *
154
	 * @param string $type
155
	 *
156
	 * @return void
157
	 */
158
	protected function setType($type)
159
	{
160
		$this->type = $type;
161
	}
162
163
	/**
164
	 * Get the locations latitude.
165
	 *
166
	 * @return float
167
	 */
168
	public function getLatitude()
169
	{
170
		return $this->latitude;
171
	}
172
173
	/**
174
	 * Set the locations latitude.
175
	 *
176
	 * @param float $latitude
177
	 *
178
	 * @return void
179
	 */
180
	protected function setLatitude($latitude)
181
	{
182
		$this->latitude = $latitude;
183
	}
184
185
	/**
186
	 * Get the locations longitude.
187
	 *
188
	 * @return float
189
	 */
190
	public function getLongitude()
191
	{
192
		return $this->longitude;
193
	}
194
195
	/**
196
	 * Set the locations longitude.
197
	 *
198
	 * @param float $longitude
199
	 *
200
	 * @return void
201
	 */
202
	protected function setLongitude($longitude)
203
	{
204
		$this->longitude = $longitude;
205
	}
206
207
	/**
208
	 * Get the place id.
209
	 *
210
	 * @return string
211
	 *
212
	 * @return string
213
	 */
214
	public function getPlaceId()
215
	{
216
		return $this->placeId;
217
	}
218
219
	/**
220
	 * Set the place id.
221
	 *
222
	 * @param string $placeId
223
	 *
224
	 * @return void
225
	 */
226
	protected function setPlaceId($placeId)
227
	{
228
		$this->placeId = $placeId;
229
	}
230
231
	/**
232
	 * Create a new map from location.
233
	 *
234
	 * @param array $options
235
	 *
236
	 * @return Mapper
237
	 */
238
	public function map(array $options = [])
239
	{
240
		return self::$mapper->map($this->getLatitude(), $this->getLongitude(), $options);
241
	}
242
243
	/**
244
	 * Create a new street view map from location.
245
	 *
246
	 * @param integer $heading
247
	 * @param integer $pitch
248
	 * @param array   $options
249
	 *
250
	 * @return Mapper
251
	 */
252
	public function streetview($heading, $pitch, array $options = [])
253
	{
254
		return self::$mapper->streetview($this->getLatitude(), $this->getLongitude(), $heading, $pitch, $options);
255
	}
256
257
}
258