Completed
Push — address-as-title ( 9b6eeb...601934 )
by Peter
11:07
created

MapsBaseFillableElement::setFillColor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @since 2.0
5
 */
6
class MapsBaseFillableElement extends MapsBaseStrokableElement implements iFillableMapElement {
7
8
	protected $fillColor;
9
	protected $fillOpacity;
10
11
	public function getFillColor() {
12
		return $this->fillColor;
13
	}
14
15
	public function setFillColor( $fillColor ) {
16
		$this->fillColor = trim($fillColor);
17
	}
18
19
	public function getFillOpacity() {
20
		return $this->fillOpacity;
21
	}
22
23
	public function setFillOpacity( $fillOpacity ) {
24
		$this->fillOpacity = trim($fillOpacity);
25
	}
26
27
	public function hasFillColor() {
28
		return !is_null( $this->fillColor ) && $this->fillColor !== '';
29
	}
30
31
	public function hasFillOpacity() {
32
		return !is_null( $this->fillOpacity ) && $this->fillOpacity !== '';
33
	}
34
35
	public function getJSONObject( $defText = '' , $defTitle = '' ) {
36
		$parentArray = parent::getJSONObject( $defText , $defTitle );
37
		$array = [
38
			'fillColor' => $this->hasFillColor() ? $this->getFillColor() : '#FF0000' ,
39
			'fillOpacity' => $this->hasFillOpacity() ? $this->getFillOpacity() : '0.5' ,
40
		];
41
		return array_merge( $parentArray , $array );
42
	}
43
}
44