Marker_Label::set_font_size()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Clubdeuce\WPGoogleMaps;
4
5
/**
6
 * Class Marker_Label
7
 * @package Clubdeuce\WPGoogleMaps
8
 */
9
class Marker_Label extends Model_Base {
10
11
	/**
12
	 * @var string
13
	 */
14
	protected $_color = 'black';
15
16
	/**
17
	 * @var null|string
18
	 */
19
	protected $_font_family = null;
20
21
	/**
22
	 * @var string
23
	 */
24
	protected $_font_size = '14px';
25
26
	/**
27
	 * @var string
28
	 */
29
	protected $_font_weight = '400';
30
31
	/**
32
	 * @var null|string
33
	 */
34
	protected $_text = '';
35
36
	/**
37
	 * @return string
38
	 */
39 3
	public function color() {
40
41 3
		return (string)$this->_color;
42
43
	}
44
45
	/**
46
	 * @return null|string
47
	 */
48 3
	public function font_family() {
49
50 3
		return (string)$this->_font_family;
51
52
	}
53
54
	/**
55
	 * @return string
56
	 */
57 3
	public function font_size() {
58
59 3
		return (string)$this->_font_size;
60
61
	}
62
63
	/**
64
	 * @return string
65
	 */
66 3
	public function font_weight() {
67
68 3
		return (string)$this->_font_weight;
69
70
	}
71
72
	/**
73
	 * @return null|string
74
	 */
75 3
	public function text() {
76
77 3
		return (string)$this->_text;
78
79
	}
80
81
	/**
82
	 * @param string $color
83
	 */
84 1
	public function set_color( $color ) {
85
86 1
		$this->_color = $color;
87
88 1
	}
89
90
	/**
91
	 * @param string $font
92
	 */
93 1
	public function set_font_family( $font ) {
94
95 1
		$this->_font_family = $font;
96
97 1
	}
98
99
	/**
100
	 * @param string $size
101
	 */
102 1
	public function set_font_size( $size ) {
103
104 1
		$this->_font_size = $size;
105
106 1
	}
107
108
	/**
109
	 * @param string $weight
110
	 */
111 1
	public function set_font_weight( $weight ) {
112
113 1
		$this->_font_weight = $weight;
114
115 1
	}
116
117
	/**
118
	 * @param string $text
119
	 */
120 1
	public function set_text( $text ) {
121
122 1
		$this->_text = $text;
123
124 1
	}
125
126
	/**
127
	 * @return string
128
	 *
129
	 * @todo Is this used? If not, remove it.
130
	 */
131 1
	public function json_object() {
132
133 1
		return json_encode( $this->options() );
134
135
	}
136
137
	/**
138
	 * @return string|array
139
	 */
140 1
	public function options() {
141
142
		$args = [
143 1
			'color'      => $this->color(),
144 1
			'fontFamily' => $this->font_family(),
145 1
			'fontSize'   => $this->font_size(),
146 1
			'fontWeight' => $this->font_weight(),
147 1
			'text'       => $this->text(),
148
		];
149
150 1
		$args = array_filter( $args, function( $value ) {
151 1
			return ! is_null( $value );
152 1
		} );
153
154
		if ( empty( $args['text'] ) ) {
155
			$args = '';
156
		}
157
158
		return $args;
159
160
	}
161
162
}
163