Completed
Push — master ( 68c2d1...79d43d )
by Angus
02:33
created

MY_Loader::database()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 11
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
class MY_Loader extends CI_Loader {
4
5 96
	public function __construct() {
6 96
		parent::__construct();
7 96
	}
8
9
	/**
10
	 * Database Loader extension, to load our version of the caching engine
11
	 *
12
	 * @access   public
13
	 *
14
	 * @param    string  the DB credentials
15
	 * @param    bool    whether to return the DB object
16
	 * @param    bool    whether to enable active record (this allows us to override the config setting)
17
	 *
18
	 * @return   object
19
	 */
20 96
	function database($params = '', $return = FALSE, $active_record = NULL) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
		// load our version of the CI_DB_Cache class. The database library checks
22
		// if this class is already loaded before instantiating it. Loading it now
23
		// makes sure our version is used when a controller enables query caching
24 96
		if(!class_exists('CI_DB_Cache')) {
25
			@include(APPPATH . 'libraries/MY_DB_cache.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
26
		}
27
28
		// call the parent method to retain the CI functionality
29 96
		return parent::database($params, $return, $active_record);
30
	}
31
}
32