MY_Controller   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 9 2
1
<?php
2
3
/**
4
 * Base controller extending CodeIgniter Controller
5
 */
6
class MY_Controller extends CI_Controller {
7
	/**
8
	 * @var Validation_Callbacks
9
	 */
10
	public $validation_callbacks;
11
12
	/**
13
	 * @var Page
14
	 */
15
	public $page;
16
17
	// --------------------------------------------------------------------------
18
19
	/**
20
	 * Validate a form field using a callback
21
	 *
22
	 * @param string $str
23
	 * @param string $rule_name
24
	 * @return mixed
25
	 * @throws InvalidArgumentException
26
	 */
27 13
	public function validate($str, $rule_name)
28
	{
29 13
		if (method_exists($this->validation_callbacks, $rule_name))
30 13
		{
31 12
			return $this->validation_callbacks->$rule_name($str);
32
		}
33
34 1
		throw new InvalidArgumentException("Validation callback '{$rule_name}' does not exist");
35
	}
36
}
37
// End of core/MY_Controller.php