Completed
Push — cleanz ( 70f885...f1882e )
by Jeroen De
26:41 queued 16:46
created

BaseFillableElement   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

7 Methods

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