MY_Loader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A database() 0 11 2
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