Completed
Push — master ( 81538e...c2bf57 )
by Jeroen De
10:06
created

BaseFillableElement::hasFillOpacity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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