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

BaseWidget   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 20
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getIdentifier() 0 3 1
A setIdentifier() 0 4 1
A cleanIdentifier() 0 3 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
}