Test Failed
Push — master ( 2ebd79...2dee01 )
by Jean-Christophe
01:41 queued 13s
created

DAOPreparedQuery::getClassName()   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 0
crap 2
1
<?php
2
3
namespace Ubiquity\orm\core\prepared;
4
5
use Ubiquity\orm\parser\ConditionParser;
6
use Ubiquity\orm\DAO;
7
use Ubiquity\orm\OrmUtils;
8
use Ubiquity\db\Database;
9
10
abstract class DAOPreparedQuery {
11
	protected $databaseOffset;
12
13
	/**
14
	 *
15
	 * @var ConditionParser
16
	 */
17
	protected $conditionParser;
18
	protected $included;
19
	protected $hasIncluded;
20
	protected $useCache;
21
	protected $className;
22
	protected $tableName;
23
	protected $invertedJoinColumns = null;
24
	protected $oneToManyFields = null;
25
	protected $manyToManyFields = null;
26
	protected $transformers;
27
	protected $propsKeys;
28
	protected $accessors;
29
	protected $fieldList;
30
	protected $firstPropKey;
31
	protected $condition;
32
	/**
33
	 *
34
	 * @var Database
35
	 */
36
	protected $db;
37
38
	public function __construct($className, $condition = null, $included = false) {
39
		$this->className = $className;
40
		$this->included = $included;
41
		$this->condition = $condition;
42
		$this->conditionParser = new ConditionParser ( $condition );
43
		$this->prepare ();
44
	}
45
46
	public function getFirstPropKey() {
47
		return $this->firstPropKey;
48
	}
49
50
	/**
51
	 *
52
	 * @return \Ubiquity\db\Database
53
	 */
54
	public function getDb() {
55
		return $this->db;
56
	}
57
58
	/**
59
	 *
60
	 * @return mixed
61
	 */
62
	public function getDatabaseOffset() {
63
		return $this->databaseOffset;
64
	}
65
66
	/**
67
	 *
68
	 * @return \Ubiquity\orm\parser\ConditionParser
69
	 */
70
	public function getConditionParser() {
71
		return $this->conditionParser;
72
	}
73
74
	/**
75
	 *
76
	 * @return mixed
77
	 */
78
	public function getIncluded() {
79
		return $this->included;
80
	}
81
82
	/**
83
	 *
84
	 * @return boolean
85
	 */
86
	public function getHasIncluded() {
87
		return $this->hasIncluded;
88
	}
89
90
	/**
91
	 *
92
	 * @return mixed
93
	 */
94
	public function getUseCache() {
95
		return $this->useCache;
96
	}
97
98
	/**
99
	 *
100
	 * @return mixed
101
	 */
102
	public function getClassName() {
103
		return $this->className;
104
	}
105
106
	/**
107
	 *
108
	 * @return mixed
109
	 */
110
	public function getTableName() {
111
		return $this->tableName;
112
	}
113
114
	/**
115
	 *
116
	 * @return mixed
117
	 */
118
	public function getInvertedJoinColumns() {
119
		return $this->invertedJoinColumns;
120
	}
121
122
	/**
123
	 *
124
	 * @return mixed
125
	 */
126
	public function getOneToManyFields() {
127
		return $this->oneToManyFields;
128
	}
129
130
	/**
131
	 *
132
	 * @return mixed
133
	 */
134
	public function getManyToManyFields() {
135
		return $this->manyToManyFields;
136
	}
137
138
	public function getTransformers() {
139
		return $this->transformers;
140
	}
141
142
	public function getPropsKeys() {
143
		return $this->propsKeys;
144
	}
145
146
	/**
147
	 *
148
	 * @return mixed
149
	 */
150
	public function getAccessors() {
151
		return $this->accessors;
152
	}
153
154
	public function getFieldList() {
155
		return $this->fieldList;
156
	}
157
158
	protected function prepare() {
159
		$this->db = DAO::getDb ( $this->className );
160
		$this->included = DAO::_getIncludedForStep ( $this->included );
161
162
		$metaDatas = OrmUtils::getModelMetadata ( $this->className );
163
		$this->tableName = $metaDatas ['#tableName'];
164
		$this->hasIncluded = $this->included || (\is_array ( $this->included ) && \sizeof ( $this->included ) > 0);
165
		if ($this->hasIncluded) {
166
			DAO::_initRelationFields ( $this->included, $metaDatas, $this->invertedJoinColumns, $this->oneToManyFields, $this->manyToManyFields );
167
		}
168
		$this->transformers = $metaDatas ['#transformers'] [DAO::$transformerOp] ?? [ ];
169
		$this->fieldList = DAO::_getFieldList ( $this->tableName, $metaDatas );
170
		$this->propsKeys = OrmUtils::getPropKeys ( $this->className );
171
		$this->accessors = $metaDatas ['#accessors'];
172
		$this->firstPropKey = OrmUtils::getFirstPropKey ( $this->className );
173
	}
174
175
	abstract public function execute($params = [], $useCache = false);
176
}
177
178