Passed
Push — master ( f5da16...2e3bf1 )
by Jean-Christophe
12:28
created

DatabaseMetadatas   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
eloc 8
c 1
b 0
f 1
dl 0
loc 33
ccs 10
cts 14
cp 0.7143
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getForeignKeys() 0 2 1
A getTablesName() 0 2 1
A getRowNum() 0 2 1
A getFieldsInfos() 0 2 1
A getPrimaryKeys() 0 2 1
A getPHPType() 0 2 1
A migrateOperation() 0 2 1
1
<?php
2
3
namespace Ubiquity\db\traits;
4
5
use Ubiquity\db\utils\DbTypes;
6
7
/**
8
 * Retreives metadatas from the database.
9
 *
10
 * Ubiquity\db\traits$DatabaseMetadatas
11
 * This class is part of Ubiquity
12
 *
13
 * @author jcheron <[email protected]>
14
 * @version 1.0.4
15
 *
16
 * @property \Ubiquity\db\providers\AbstractDbWrapper $wrapperObject
17
 */
18
trait DatabaseMetadatas {
19
20 4
	public function getTablesName() {
21 4
		return $this->wrapperObject->getTablesName ();
22
	}
23
24 1
	public function getPrimaryKeys($tableName) {
25 1
		return $this->wrapperObject->getPrimaryKeys ( $tableName );
26
	}
27
28 1
	public function getFieldsInfos($tableName) {
29 1
		return $this->wrapperObject->getFieldsInfos ( $tableName );
30
	}
31
32 1
	public function getForeignKeys($tableName, $pkName, $dbName = null) {
33 1
		return $this->wrapperObject->getForeignKeys ( $tableName, $pkName, $dbName );
34
	}
35
36 4
	public function getRowNum(string $tableName, string $pkName, string $condition): int {
37 4
		return $this->wrapperObject->getRowNum ( $tableName, $pkName, $condition );
38
	}
39
40
	public function getPHPType(string $dbType): string {
41
		return DbTypes::asPhpType($dbType);
42
	}
43
	
44
	/**
45
	 * Returns the SQL command for a migration operation. 
46
	 * @param string $operation The migration to opere
47
	 * @return string The generated SQL string
48
	 */
49
	public function migrateOperation(string $operation):string {
50
		return $this->wrapperObject->migrateOperation($operation);
51
	}
52
}
53
54