Completed
Push — master ( d40e31...09d055 )
by Daryl
01:35
created

Map_Model::make_args()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
5
/**
6
 * Class Map_Model
7
 * @package Clubdeuce\WPLib\Components\GoogleMaps
8
 */
9
class Map_Model extends \WPLib_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 ) {
49
50 1
        $this->_markers[] = $marker;
51
52 1
    }
53
54
    /**
55
     * @param Marker[] $markers
56
     */
57 1
    function add_markers( $markers ) {
58
59 1
        $this->_markers = array_merge( $this->_markers, $markers );
60
61 1
    }
62
63
    /**
64
     * @return array
65
     */
66 1
    function center() {
67
68 1
        return $this->_center;
69
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    function height() {
76
77
        return $this->_height;
78
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    function html_id() {
85
86
        if ( ! isset( $this->_html_id ) ) {
87
            $this->_html_id = sprintf( 'map-%1$s', md5( serialize( array( $this->center(), $this->markers() ) ) ) );
88
        }
89
90
        return $this->_html_id;
91
92
    }
93
94
    /**
95
     * @return Marker[]
96
     */
97 1
    function markers() {
98
99 1
        return $this->_markers;
100
101
    }
102
103
    /**
104
     * @return string
105
     */
106
    function width() {
107
108
        return $this->_width;
109
110
    }
111
112
    /**
113
     * @return int
114
     */
115 1
    function zoom() {
116
117 1
        return $this->_zoom;
118
119
    }
120
121
	/**
122
	 * @return array
123
	 */
124 1
	function make_args() {
125
126
		return array(
127 1
			'center' => $this->center(),
128 1
			'zoom'   => (int)$this->zoom()
129
		);
130
131
	}
132
133
}
134