Test Failed
Push — master ( c36a4e...c6936f )
by Jean-Christophe
03:13
created

AbstractDbWrapper::setDbInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Ubiquity\db\providers;
4
5
/**
6
 * Ubiquity\db\providers$AbstractDbWrapper
7
 * This class is part of Ubiquity
8
 *
9
 * @author jcheron <[email protected]>
10
 * @version 1.0.0
11
 *
12
 */
13
abstract class AbstractDbWrapper {
14
	protected $dbInstance;
15
	protected $statements;
16
	public $quote;
17
18
	abstract public function query(string $sql);
19
20
	abstract public function queryAll(string $sql, int $fetchStyle = null);
21
22
	abstract public function queryColumn(string $sql, int $columnNumber = null);
23
24
	abstract public static function getAvailableDrivers();
25
26 68
	public function _getStatement(string $sql) {
27 68
		$key = \md5 ( $sql );
28 68
		if (! isset ( $this->statements [$key] )) {
29 68
			$this->statements [$key] = $this->getStatement ( $sql );
30
		}
31 68
		return $this->statements [$key];
32
	}
33
34
	abstract public function getStatement(string $sql);
35
36
	abstract public function connect(string $dbType, $dbName, $serverName, string $port, string $user, string $password, array $options);
37
38
	abstract public function getDSN(string $serverName, string $port, string $dbName, string $dbType = 'mysql');
39
40
	abstract public function execute(string $sql);
41
42
	abstract public function prepareStatement(string $sql);
43
44
	abstract public function executeStatement($statement, array $values = null);
45
46
	abstract public function statementRowCount($statement);
47
48
	abstract public function lastInsertId();
49
50
	/**
51
	 * Used by DAO
52
	 *
53
	 * @param mixed $statement
54
	 * @param string $parameter
55
	 * @param mixed $value
56
	 */
57
	abstract public function bindValueFromStatement($statement, $parameter, $value);
58
59
	abstract public function fetchColumn($statement, array $values = null, int $columnNumber = null);
60
61
	abstract public function fetchAll($statement, array $values = null, $mode = null);
62
63
	abstract public function fetchOne($statement, array $values = null, $mode = null);
64
65
	abstract public function fetchAllColumn($statement, array $values = null, string $column = null);
66
67
	abstract public function getTablesName();
68
69
	abstract public function beginTransaction();
70
71
	abstract public function commit();
72
73
	abstract public function inTransaction();
74
75
	abstract public function rollBack();
76
77
	abstract public function nestable();
78
79
	abstract public function savePoint($level);
80
81
	abstract public function releasePoint($level);
82
83
	abstract public function rollbackPoint($level);
84
85
	abstract public function ping();
86
87
	abstract public function getPrimaryKeys($tableName);
88
89
	abstract public function getFieldsInfos($tableName);
90
91
	abstract public function getForeignKeys($tableName, $pkName, $dbName = null);
92
93
	abstract public function _optPrepareAndExecute($sql, array $values = null);
94
95 28
	public function close() {
96 28
		$this->dbInstance = null;
97 28
	}
98
99
	/**
100
	 *
101
	 * @return object
102
	 */
103 2
	public function getDbInstance() {
104 2
		return $this->dbInstance;
105
	}
106
107
	/**
108
	 *
109
	 * @param object $dbInstance
110
	 */
111
	public function setDbInstance($dbInstance) {
112
		$this->dbInstance = $dbInstance;
113
	}
114
115
	public function quoteValue($value, $type = null) {
1 ignored issue
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

115
	public function quoteValue($value, /** @scrutinizer ignore-unused */ $type = null) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
116
		return "'" . \addslashes ( $value ) . "'";
117
	}
118
}