Completed
Push — master ( 3ffb85...062fc7 )
by Daryl
04:57
created

Map::set_zoom()   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 3
	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 3
		return $this->_center;
69
70
	}
71
72
	/**
73
	 * @return string
74
	 */
75 2
	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 2
		return $this->_height;
78
79
	}
80
81
	/**
82
	 * @return string
83
	 */
84 2
	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 2
		if ( ! isset( $this->_html_id ) ) {
87 1
			$this->_html_id = sprintf( 'map-%1$s', md5( serialize( array( $this->center(), $this->markers() ) ) ) );
88
		}
89
90 2
		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 3
	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 3
		return $this->_zoom;
118
119
	}
120
121
	/**
122
	 * @param array $center
123
	 */
124 1
	function set_center( $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...
125
126 1
		$center = wp_parse_args( $center, array(
127 1
			'lat' => null,
128
			'lng' => null,
129
		) );
130
131 1
		$this->_center = $center;
132
133 1
	}
134
135
	/**
136
	 * @param int $zoom
137
	 */
138 1
	function set_zoom( $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...
139
140 1
		$this->_zoom = (int)$zoom;
141
142 1
	}
143
144
	/**
145
	 * @param string $height
146
	 */
147 1
	function set_height( $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...
148
149 1
		$this->_height = $height;
150
151 1
	}
152
153
	/**
154
	 * @param string $id
155
	 */
156 1
	function set_html_id( $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...
157
158 1
		$this->_html_id = $id;
159
160 1
	}
161
162
	/**
163
	 * @return array
164
	 *
165
	 * @todo Refactor to make_params
166
	 */
167 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...
168
169
		return array(
170 1
			'center' => $this->center(),
171 1
			'zoom'   => (int)$this->zoom(),
172
		);
173
174
	}
175
176
}
177