Passed
Push — master ( 668422...591315 )
by Jean-Christophe
20:17
created

FlashMessage   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Test Coverage

Coverage 67.74%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 24
c 1
b 0
f 0
dl 0
loc 82
ccs 21
cts 31
cp 0.6774
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A setValues() 0 5 1
A setContent() 0 2 1
A getTitle() 0 2 1
A getIcon() 0 2 1
A setType() 0 2 1
A getType() 0 2 1
A setTitle() 0 2 1
A setIcon() 0 2 1
A getContent() 0 2 1
A parseContent() 0 7 2
A addType() 0 2 1
1
<?php
2
3
namespace Ubiquity\utils\flash;
4
5
class FlashMessage {
6
	protected ?string $title;
7
	protected ?string $content;
8
	protected ?string $type;
9
	protected ?string $icon;
10
11 9
	public function __construct(string $content,string $title=NULL,string $type='info',string $icon=null){
12 9
		$this->setValues($content,$title,$type,$icon);
13
	}
14
	
15 9
	public function setValues(string $content,string $title=NULL,string $type=NULL,string $icon=null){
16 9
		$this->type = $type;
17 9
		$this->content=$content;
18 9
		$this->icon = $icon;
19 9
		$this->title = $title;
20
	}
21
	/**
22
	 * @return string|null
23
	 */
24 4
	public function getContent(): ?string {
25 4
		return $this->content;
26
	}
27
28
	/**
29
	 * @return string
30
	 */
31 4
	public function getType(): ?string {
32 4
		return $this->type;
33
	}
34
35
	/**
36
	 * @return string|null
37
	 */
38 2
	public function getIcon(): ?string {
39 2
		return $this->icon;
40
	}
41
42
	/**
43
	 * @param string $content
44
	 */
45
	public function setContent(string $content) {
46
		$this->content = $content;
47
	}
48
49
	/**
50
	 * @param string $type
51
	 */
52
	public function setType(string $type) {
53
		$this->type = $type;
54
	}
55
	
56
	public function addType(string $type){
57
		$this->type.=' '.$type;
58
	}
59
60
	/**
61
	 * @param string $icon
62
	 */
63
	public function setIcon(string $icon) {
64
		$this->icon = $icon;
65
	}
66
	/**
67
	 * @return string|null
68
	 */
69 3
	public function getTitle(): ?string {
70 3
		return $this->title;
71
	}
72
73
	/**
74
	 * @param string $title
75
	 */
76
	public function setTitle(string $title) {
77
		$this->title = $title;
78
	}
79
	
80 2
	public function parseContent(array $keyValues): self {
81 2
		$msg=$this->content;
82 2
		foreach ($keyValues as $key=>$value){
83 2
			$msg=\str_replace('{'.$key.'}', $value, $msg);
84
		}
85 2
		$this->content=$msg;
86 2
		return $this;
87
	}
88
}
89