Completed
Push — master ( e38a14...2bd32e )
by Kenji
11s
created

CIPHPUnitTestDbConnectionStore   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A destory() 0 8 2
A closeConnection() 0 6 3
1
<?php
2
3
class CIPHPUnitTestDbConnectionStore
4
{
5
	private static $connections = [];
6
7
	public static function add(CI_DB $db)
8
	{
9
		self::$connections[] = $db;
10
	}
11
12
	public static function destory()
13
	{
14
		foreach (self::$connections as $db) {
15
			self::closeConnection($db);
16
		}
17
18
		self::$connections = [];
19
	}
20
21
	private static function closeConnection(CI_DB $db)
22
	{
23
		if ($db->dsn !== 'sqlite::memory:' && $db->database !== ':memory:') {
24
			$db->close();
25
		}
26
	}
27
}
28