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

FlashMessage::setContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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