MY_Loader::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed');
2
3
class MY_Loader extends CI_Loader {
4 96
	public function __construct() {
5 96
		parent::__construct();
6 96
	}
7
8
	/**
9
	 * Database Loader extension, to load our version of the caching engine
10
	 *
11
	 * @access   public
12
	 *
13
	 * @param    string  $params         the DB credentials
14
	 * @param    bool    $return         whether to return the DB object
15
	 * @param    bool    $active_record  whether to enable active record (this allows us to override the config setting)
16
	 *
17
	 * @return   object
18
	 */
19 96
	public function database($params = '', $return = FALSE, $active_record = NULL) {
20
		// load our version of the CI_DB_Cache class. The database library checks
21
		// if this class is already loaded before instantiating it. Loading it now
22
		// makes sure our version is used when a controller enables query caching
23 96
		if(!class_exists('CI_DB_Cache')) {
24
			@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...
25
		}
26
27
		// call the parent method to retain the CI functionality
28 96
		return parent::database($params, $return, $active_record);
29
	}
30
}
31