Completed
Push — master ( b9a8b8...3e8704 )
by Jean-Christophe
03:43
created

BaseWidget::__construct()   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
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Ajax\common\html;
4
5
/**
6
 * BaseWidget for Twitter Bootstrap or Semantic components
7
 * @author jc
8
 * @version 1.001
9
 */
10
abstract class BaseWidget {
11
	protected $identifier;
12
13
	public function __construct($identifier) {
14
		$this->identifier=$this->cleanIdentifier($identifier);
15
	}
16
17
	public function getIdentifier() {
18
		return $this->identifier;
19
	}
20
21
	public function setIdentifier($identifier) {
22
		$this->identifier=$identifier;
23
		return $this;
24
	}
25
26
	protected function cleanIdentifier($id) {
27
		return preg_replace('/[^a-zA-Z0-9\-.]/s', '', $id);
28
	}
29
}