Passed
Push — master ( 213516...f477f5 )
by Jean-Christophe
04:14
created

CRUDMessage::parse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Ubiquity\controllers\crud;
4
5
class CRUDMessage {
6
	private $message;
7
	private $type;
8
	private $icon;
9
	private $title;
10
	private $timeout;
11
	private $_message;
12
	
13 1
	public function __construct($message,$title="",$type="",$icon="",$timeout=null){
14 1
		$this->message=$message;
15 1
		$this->title=$title;
16 1
		$this->type=$type;
17 1
		$this->icon=$icon;
18 1
		$this->timeout=$timeout;
19 1
		$this->_message=$message;
20 1
	}
21
	
22
	/**
23
	 * @return string
24
	 */
25 1
	public function getMessage() {
26 1
		return $this->_message;
27
	}
28
29
	/**
30
	 * @return string
31
	 */
32 1
	public function getType() {
33 1
		return $this->type;
34
	}
35
36
	/**
37
	 * @return mixed
38
	 */
39 1
	public function getIcon() {
40 1
		return $this->icon;
41
	}
42
43
	/**
44
	 * @return string
45
	 */
46 1
	public function getTitle() {
47 1
		return $this->title;
48
	}
49
50
	/**
51
	 * @param string $message
52
	 */
53
	public function setMessage($message) {
54
		$this->_message = $message;
55
		$this->message=$message;
56
		return $this;
57
	}
58
59
	/**
60
	 * @param string $type
61
	 * @return $this
62
	 */
63 1
	public function setType($type) {
64 1
		$this->type = $type;
65 1
		return $this;
66
	}
67
68
	/**
69
	 * @param string $icon
70
	 * @return $this
71
	 */
72 1
	public function setIcon($icon) {
73 1
		$this->icon = $icon;
74 1
		return $this;
75
	}
76
77
	/**
78
	 * @param string $title
79
	 * @return $this
80
	 */
81
	public function setTitle($title) {
82
		$this->title = $title;
83
		return $this;
84
	}
85
	
86
	/**
87
	 * @return integer
88
	 */
89 1
	public function getTimeout() {
90 1
		return $this->timeout;
91
	}
92
93
	/**
94
	 * @param integer $timeout
95
	 * @return $this
96
	 */
97
	public function setTimeout($timeout) {
98
		$this->timeout = $timeout;
99
		return $this;
100
	}
101
	/**
102
	 * 
103
	 * @param string $value
104
	 * @return $this
105
	 */
106
	public function parse($value){
107
		$this->_message=str_replace("{value}", $value, $this->message);
108
		return $this;
109
	}
110
	
111
	public function parseContent($keyValues){
112
		$msg=$this->_message;
113
		foreach ($keyValues as $key=>$value){
114
			$msg=str_replace("{".$key."}", $value, $msg);
115
		}
116
		$this->_message=$msg;
117
		return $this;
118
	}
119
120
}
121
122