Completed
Push — cleanz ( d9e779 )
by Jeroen De
06:06
created

BaseElement   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 46
ccs 12
cts 21
cp 0.5714
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setTitle() 0 3 1
A setText() 0 3 1
A setLink() 0 3 1
A getArrayValue() 0 3 1
A getJSONObject() 0 7 1
A getText() 0 3 1
A getTitle() 0 3 1
A getLink() 0 3 1
1
<?php
2
3
namespace Maps\Elements;
4
5
/**
6
 * @since 3.0
7
 *
8
 * @licence GNU GPL v2+
9
 * @author Kim Eik < [email protected] >
10
 * @author Jeroen De Dauw < [email protected] >
11
 */
12
abstract class BaseElement {
13
14
	private $title;
15
	private $text;
16
	private $link;
17
18 8
	public function setTitle( string $title ) {
19 8
		$this->title = trim( $title );
20 8
	}
21
22 5
	public function setText( string $text ) {
23 5
		$this->text = trim( $text );
24 5
	}
25
26
	public function setLink( string $link ) {
27
		$this->link = $link;
28
	}
29
30 5
	public function getArrayValue() {
31 5
		return $this->getJSONObject();
0 ignored issues
show
Deprecated Code introduced by
The method Maps\Elements\BaseElement::getJSONObject() has been deprecated.

This method has been deprecated.

Loading history...
32
	}
33
34
	/**
35
	 * @deprecated
36
	 */
37 18
	public function getJSONObject( string $defText = '', string $defTitle = '' ): array {
38
		return [
39 18
			'text' => $this->text ?? $defText,
40 18
			'title' => $this->title ?? $defTitle,
41 18
			'link' => $this->link ?? '',
42
		];
43
	}
44
45
	public function getText(): string {
46
		return $this->text ?? '';
47
	}
48
49
	public function getTitle(): string {
50
		return $this->title ?? '';
51
	}
52
53
	public function getLink(): string {
54
		return $this->link ?? '';
55
	}
56
57
}
58