Custom_validation   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 43
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
set_validation_rules() 0 1 ?
A __construct() 0 7 1
A set_error_delimiters() 0 4 1
A set_rules() 0 6 1
A validate() 0 10 2
A run() 0 4 1
1
<?php
2
3
abstract class Custom_validation
4
{
5
	private $CI;
6
7
	public function __construct()
8
	{
9
		$this->CI =& get_instance();
10
		$this->CI->load->library('form_validation');
11
12
		$this->set_validation_rules();
13
	}
14
15
	// バリデーションの設定
16
	abstract protected function set_validation_rules();
17
18
	protected function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
19
	{
20
		$this->CI->form_validation->set_error_delimiters($prefix, $suffix);
0 ignored issues
show
Bug introduced by
The property form_validation does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
21
	}
22
23
	protected function set_rules(
24
		$field, $label = '', $rules = array(), $errors = array()
25
	)
26
	{
27
		$this->CI->form_validation->set_rules($field, $label, $rules, $errors);
0 ignored issues
show
Bug introduced by
The property form_validation does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
28
	}
29
30
	public function validate(array $data = [])
31
	{
32
		if ($data !== [])
33
		{
34
			$this->CI->form_validation->set_data($data);
0 ignored issues
show
Bug introduced by
The property form_validation does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
35
			$this->set_validation_rules();
36
		}
37
38
		return $this->run();
39
	}
40
41
	public function run()
42
	{
43
		return $this->CI->form_validation->run();
0 ignored issues
show
Bug introduced by
The property form_validation does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
44
	}
45
}
46