DatabaseFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 19 2
1
<?php
2
3
namespace Zortje\MySQLKeeper;
4
5
use Zortje\MySQLKeeper\Database\TableCollection;
6
use Zortje\MySQLKeeper\Database\TableFactory;
7
8
/**
9
 * Class DatabaseFactory
10
 *
11
 * @package Zortje\MySQLKeeper
12
 */
13
class DatabaseFactory {
14
15
	/**
16
	 * Create database
17
	 *
18
	 * @param \PDO $pdo Database connection
19
	 *
20
	 * @return Database
21
	 */
22 2
	public static function create(\PDO $pdo) {
23
		/**
24
		 * Tables
25
		 */
26 2
		$tables = new TableCollection();
27
28 2
		foreach ($pdo->query('SHOW TABLES;') as $row) {
29 2
			$table = TableFactory::create($row[0], $pdo);
30
31 2
			$tables->add($table);
32 2
		}
33
34
		/**
35
		 * Initialization
36
		 */
37 2
		$database = new Database($tables);
38
39 2
		return $database;
40
	}
41
}
42