Completed
Push — master ( 1a7397...8cd977 )
by Daryl
04:36
created

Map::add_markers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Clubdeuce\WPGoogleMaps;
4
5
/**
6
 * Class Map
7
 * @package Clubdeuce\WPGoogleMaps
8
 */
9
class Map extends Model_Base {
10
11
	/**
12
	 * @var array
13
	 */
14
	protected $_center;
15
16
	/**
17
	 * The Map element height (default: 400px).
18
	 * @var string
19
	 */
20
	protected $_height = '400px';
21
22
	/**
23
	 * The string to use for the map HTML element id property
24
	 *
25
	 * @var string
26
	 */
27
	protected $_html_id;
28
29
	/**
30
	 * @var Marker[]
31
	 */
32
	protected $_markers = array();
33
34
	/**
35
	 * The Map element width (default: 100%).
36
	 * @var string
37
	 */
38
	protected $_width = '100%';
39
40
	/**
41
	 * @var int
42
	 */
43
	protected $_zoom = 5;
44
45
	/**
46
	 * @param Marker $marker
47
	 */
48 1
	function add_marker( $marker ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
49
50 1
		$this->_markers[] = $marker;
51
52 1
	}
53
54
	/**
55
	 * @param Marker[] $markers
56
	 */
57 1
	function add_markers( $markers ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
58
59 1
		$this->_markers = array_merge( $this->_markers, $markers );
60
61 1
	}
62
63
	/**
64
	 * @return array
65
	 */
66 2
	function center() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
67
68 2
		return $this->_center;
69
70
	}
71
72
	/**
73
	 * @return string
74
	 */
75 1
	function height() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
76
77 1
		return $this->_height;
78
79
	}
80
81
	/**
82
	 * @return string
83
	 */
84 1
	function html_id() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
85
86 1
		if ( ! isset( $this->_html_id ) ) {
87 1
			$this->_html_id = sprintf( 'map-%1$s', md5( serialize( array( $this->center(), $this->markers() ) ) ) );
88
		}
89
90 1
		return $this->_html_id;
91
92
	}
93
94
	/**
95
	 * @return Marker[]
96
	 */
97 1
	function markers() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
98
99 1
		return $this->_markers;
100
101
	}
102
103
	/**
104
	 * @return string
105
	 */
106 1
	function width() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
107
108 1
		return $this->_width;
109
110
	}
111
112
	/**
113
	 * @return int
114
	 */
115 2
	function zoom() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
116
117 2
		return $this->_zoom;
118
119
	}
120
121
	/**
122
	 * @return array
123
	 *
124
	 * @todo Refactor to make_params
125
	 */
126 1
	function make_args() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
127
128
		return array(
129 1
			'center' => $this->center(),
130 1
			'zoom'   => (int)$this->zoom(),
131
		);
132
133
	}
134
135
}
136