Passed
Push — master ( bd3cb9...127ddb )
by Jean-Christophe
17:45
created

FlashMessage   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Test Coverage

Coverage 70.59%

Importance

Changes 0
Metric Value
wmc 16
eloc 27
dl 0
loc 85
ccs 24
cts 34
cp 0.7059
rs 10
c 0
b 0
f 0

12 Methods

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