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

CIPHPUnitTestDbConnectionStore::destory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
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