Completed
Push — master ( fb8a98...3ffb85 )
by Daryl
01:25
created

Marker_Label::set_text()   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 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
	function color() {
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...
40
41 3
		return (string)$this->_color;
42
43
	}
44
45
	/**
46
	 * @return null|string
47
	 */
48 3
	function font_family() {
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 3
		return (string)$this->_font_family;
51
52
	}
53
54
	/**
55
	 * @return string
56
	 */
57 3
	function font_size() {
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 3
		return (string)$this->_font_size;
60
61
	}
62
63
	/**
64
	 * @return string
65
	 */
66 3
	function font_weight() {
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 (string)$this->_font_weight;
69
70
	}
71
72
	/**
73
	 * @return null|string
74
	 */
75 3
	function text() {
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 3
		return (string)$this->_text;
78
79
	}
80
81
	/**
82
	 * @param string $color
83
	 */
84 1
	function set_color( $color ) {
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
		$this->_color = $color;
87
88 1
	}
89
90
	/**
91
	 * @param string $font
92
	 */
93 1
	function set_font_family( $font ) {
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...
94
95 1
		$this->_font_family = $font;
96
97 1
	}
98
99
	/**
100
	 * @param string $size
101
	 */
102 1
	function set_font_size( $size ) {
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...
103
104 1
		$this->_font_size = $size;
105
106 1
	}
107
108
	/**
109
	 * @param string $weight
110
	 */
111 1
	function set_font_weight( $weight ) {
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...
112
113 1
		$this->_font_weight = $weight;
114
115 1
	}
116
117
	/**
118
	 * @param string $text
119
	 */
120 1
	function set_text( $text ) {
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...
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
	function json_object() {
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...
132
133 1
		return json_encode( $this->options() );
134
135
	}
136
137
	/**
138
	 * @return string|array
139
	 */
140 1
	function options() {
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...
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