Code Duplication    Length = 25-26 lines in 3 locations

src/Cornford/Googlmapper/Mapper.php 3 locations

@@ 254-278 (lines=25) @@
251
	 *
252
	 * @return self
253
	 */
254
	public function polygon(array $coordinates = [], array $options = [])
255
	{
256
		$items = $this->getItems();
257
		$parameters = $this->getOptions();
258
259
		$defaults = [
260
			'coordinates' => $coordinates,
261
			'strokeColor' => '#FF0000',
262
			'strokeOpacity' => 0.8,
263
			'strokeWeight' => 2,
264
			'fillColor' => '#FF0000',
265
			'fillOpacity' => 0.35,
266
			'editable' => false
267
		];
268
		$options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options);
269
270
		if (empty($items)) {
271
			throw new MapperException('No map found to add a polygon to.');
272
		}
273
274
		$item = end($items);
275
		$item->shape('polygon', $coordinates, $options);
276
277
		return $this;
278
	}
279
280
	/**
281
	 * Add a new map rectangle.
@@ 290-314 (lines=25) @@
287
	 *
288
	 * @return self
289
	 */
290
	public function rectangle(array $coordinates = [], array $options = [])
291
	{
292
		$items = $this->getItems();
293
		$parameters = $this->getOptions();
294
295
		$defaults = [
296
			'coordinates' => $coordinates,
297
			'strokeColor' => '#FF0000',
298
			'strokeOpacity' => 0.8,
299
			'strokeWeight' => 2,
300
			'fillColor' => '#FF0000',
301
			'fillOpacity' => 0.35,
302
			'editable' => false
303
		];
304
		$options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options);
305
306
		if (empty($items)) {
307
			throw new MapperException('No map found to add a rectangle to.');
308
		}
309
310
		$item = end($items);
311
		$item->shape('rectangle', $coordinates, $options);
312
313
		return $this;
314
	}
315
316
	/**
317
	 * Add a new map circle.
@@ 326-351 (lines=26) @@
323
	 *
324
	 * @return self
325
	 */
326
	public function circle(array $coordinates = [], array $options = [])
327
	{
328
		$items = $this->getItems();
329
		$parameters = $this->getOptions();
330
331
		$defaults = [
332
			'coordinates' => $coordinates,
333
			'strokeColor' => '#FF0000',
334
			'strokeOpacity' => 0.8,
335
			'strokeWeight' => 2,
336
			'fillColor' => '#FF0000',
337
			'fillOpacity' => 0.35,
338
			'radius' => 100000,
339
			'editable' => false
340
		];
341
		$options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options);
342
343
		if (empty($items)) {
344
			throw new MapperException('No map found to add a circle to.');
345
		}
346
347
		$item = end($items);
348
		$item->shape('circle', $coordinates, $options);
349
350
		return $this;
351
	}
352
353
}
354