Seeder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A call() 0 7 1
A __get() 0 4 1
1
<?php
2
/**
3
 * 『CodeIgniter徹底入門』のサンプルアプリケーションをCodeIgniter 3.0にアップデート
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    BSD 3-Clause License
7
 * @copyright  2015 Kenji Suzuki
8
 * @link       https://github.com/kenjis/codeigniter-tettei-apps
9
 */
10
11
class Seeder
12
{
13
	private $CI;
14
	protected $db;
15
	protected $dbforge;
16
17
	public function __construct()
18
	{
19
		$this->CI =& get_instance();
20
		$this->CI->load->database();
21
		$this->CI->load->dbforge();
22
		$this->db = $this->CI->db;
0 ignored issues
show
Bug introduced by
The property db 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...
23
		$this->dbforge = $this->CI->dbforge;
0 ignored issues
show
Bug introduced by
The property dbforge 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...
24
	}
25
26
	/**
27
	 * Run another seeder
28
	 * 
29
	 * @param string $seeder Seeder classname
30
	 */
31
	public function call($seeder)
32
	{
33
		$file = APPPATH . 'database/seeds/' . $seeder . '.php';
34
		require_once $file;
35
		$obj = new $seeder;
36
		$obj->run();
37
	}
38
39
	public function __get($property)
40
	{
41
		return $this->CI->$property;
42
	}
43
}
44