Completed
Push — master ( 934849...10255c )
by Daryl
01:34
created

Marker_Label_Model::font_family()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

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 5
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
5
/**
6
 * Class Marker_Label_Model
7
 * @package Clubdeuce\WPLib\Components\GoogleMaps
8
 */
9
class Marker_Label_Model extends \WPLib_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() {
40
41 3
        return (string)$this->_color;
42
43
    }
44
45
    /**
46
     * @return null|string
47
     */
48 3
    function font_family() {
49
50 3
        return (string)$this->_font_family;
51
52
    }
53
54
    /**
55
     * @return string
56
     */
57 3
    function font_size() {
58
59 3
        return (string)$this->_font_size;
60
61
    }
62
63
    /**
64
     * @return string
65
     */
66 3
    function font_weight() {
67
68 3
        return (string)$this->_font_weight;
69
70
    }
71
72
    /**
73
     * @return null|string
74
     */
75 3
    function text() {
76
77 3
        return (string)$this->_text;
78
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    function json_object() {
85
86
        return json_encode( $this->options() );
87
88
    }
89
90
    /**
91
     * @return string|array
92
     */
93 1
    function options() {
94
95
        $args = [
96 1
            'color'      => $this->color(),
97 1
            'fontFamily' => $this->font_family(),
98 1
            'fontSize'   => $this->font_size(),
99 1
            'fontWeight' => $this->font_weight(),
100 1
            'text'       => $this->text(),
101
        ];
102
103 1
        $args = array_filter( $args, function( $value ) {
104 1
            return ! is_null( $value );
105 1
        } );
106
107
        if ( empty( $args['text'] ) ) {
108
            $args = '';
109
        }
110
111
        return $args;
112
113
    }
114
115
}
116