Completed
Branch FET-9594-attendee-mover (f0632e)
by
unknown
335:55 queued 321:12
created

ProgressStep::isCurrent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace EventEspresso\core\services\progress_steps;
3
4
use EventEspresso\Core\Exceptions\InvalidDataTypeException;
5
6
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
	exit( 'No direct script access allowed' );
8
}
9
10
11
12
/**
13
 * Class ProgressStep
14
 * Description
15
 *
16
 * @package       Event Espresso
17
 * @subpackage    core
18
 * @author        Brent Christensen
19
 * @since         $VID:$
20
 */
21
class ProgressStep implements ProgressStepInterface{
22
23
24
	/**
25
	 * @var boolean $is_current
26
	 */
27
	protected $is_current = false;
28
29
30
	/**
31
	 * @var boolean $completed
32
	 */
33
	protected $completed = false;
34
35
36
	/**
37
	 * @var string $html_class
38
	 */
39
	protected $html_class;
40
41
	/**
42
	 * @var string $id
43
	 */
44
	protected $id = '';
45
46
	/**
47
	 * @var int $order
48
	 */
49
	protected $order = 0;
50
51
	/**
52
	 * @var string $text
53
	 */
54
	protected $text = '';
55
56
57
58
	/**
59
	 * ProgressStep constructor
60
	 *
61
	 * @param int $order
62
	 * @param string $id
63
	 * @param string $html_class
64
	 * @param string $text
65
	 * @throws InvalidDataTypeException
66
	 */
67
	public function __construct( $order, $id, $html_class, $text ) {
68
		$this->setOrder( $order );
69
		$this->setId( $id );
70
		$this->setHtmlClass( $html_class );
71
		$this->setText( $text );
72
	}
73
74
75
76
	/**
77
	 * @return boolean
78
	 */
79
	public function isCurrent() {
80
		return $this->is_current;
81
	}
82
83
84
85
	/**
86
	 * @param boolean $is_current
87
	 */
88
	public function setIsCurrent( $is_current = true ) {
89
		$this->is_current = filter_var( $is_current, FILTER_VALIDATE_BOOLEAN );
90
	}
91
92
93
94
	/**
95
	 * @return boolean
96
	 */
97
	public function completed() {
98
		return $this->completed;
99
	}
100
101
102
103
	/**
104
	 * @param boolean $completed
105
	 */
106
	public function setCompleted( $completed = true ) {
107
		$this->completed = filter_var( $completed, FILTER_VALIDATE_BOOLEAN );
108
	}
109
110
111
112
	/**
113
	 * @return string
114
	 */
115
	public function id() {
116
		return $this->id;
117
	}
118
119
120
121
	/**
122
	 * @access protected
123
	 * @param string $id
124
	 * @throws InvalidDataTypeException
125
	 */
126
	protected function setId( $id = '' ) {
127
		if ( ! is_string( $id ) ) {
128
			throw new InvalidDataTypeException( '$id', $id, 'string' );
129
		}
130
		$this->id = $id;
131
	}
132
133
134
135
136
	/**
137
	 * @return int
138
	 */
139
	public function order() {
140
		return $this->order;
141
	}
142
143
144
145
	/**
146
	 * @access protected
147
	 * @param int $order
148
	 * @throws InvalidDataTypeException
149
	 */
150
	protected function setOrder( $order = 0 ) {
151
		if ( ! is_int( $order ) ) {
152
			throw new InvalidDataTypeException( '$order', $order, 'integer' );
153
		}
154
		$this->order = $order;
155
	}
156
157
158
159
	/**
160
	 * @return string
161
	 */
162
	public function htmlClass() {
163
		return $this->is_current ? $this->html_class . ' progress-step-active' : $this->html_class;
164
	}
165
166
167
168
	/**
169
	 * @access protected
170
	 * @param string $html_class
171
	 * @throws InvalidDataTypeException
172
	 */
173
	protected function setHtmlClass( $html_class ) {
174
		if ( ! is_string( $html_class ) ) {
175
			throw new InvalidDataTypeException( '$html_class', $html_class, 'string' );
176
		}
177
		if ( strpos( $html_class, 'progress-step-' ) === false ) {
178
			$html_class = 'progress-step-' . $html_class;
179
		}
180
		$this->html_class = $html_class;
181
	}
182
183
184
185
	/**
186
	 * @return string
187
	 */
188
	public function text() {
189
		return $this->text;
190
	}
191
192
193
194
	/**
195
	 * @access protected
196
	 * @param string $text
197
	 * @throws InvalidDataTypeException
198
	 */
199
	protected function setText( $text ) {
200
		if ( ! is_string( $text ) ) {
201
			throw new InvalidDataTypeException( '$text', $text, 'string' );
202
		}
203
		$this->text = $text;
204
	}
205
206
207
208
}
209
// End of file ProgressStep.php
210
// Location: /ProgressStep.php