Completed
Push — master ( 8eb0a3...82107d )
by Ron
07:34
created
src/Builder/Traits/OrderByBuilder.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 	 * @return $this
16 16
 	 */
17 17
 	public function orderBy($expression, $direction = 'asc') {
18
-		if($expression instanceof OrderBySpecification) {
19
-			foreach($expression->getFields() as $field) {
18
+		if ($expression instanceof OrderBySpecification) {
19
+			foreach ($expression->getFields() as $field) {
20 20
 				$this->addOrder($field[0], $field[1]);
21 21
 			}
22 22
 			return $this;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function orderByValues($fieldName, array $values) {
34 34
 		$expr = [];
35
-		foreach(array_values($values) as $idx => $value) {
35
+		foreach (array_values($values) as $idx => $value) {
36 36
 			$expr[] = $this->db()->quoteExpression("WHEN ? THEN ?", [$value, $idx]);
37 37
 		}
38 38
 		$this->orderBy[] = [sprintf("CASE %s\n\t\t%s\n\tEND", $this->db()->quoteField($fieldName), join("\n\t\t", $expr)), 'ASC'];
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 * @return string
45 45
 	 */
46 46
 	protected function buildOrder($query) {
47
-		if(!count($this->orderBy)) {
47
+		if (!count($this->orderBy)) {
48 48
 			return $query;
49 49
 		}
50 50
 		$query .= "ORDER BY\n";
51 51
 		$arr = [];
52
-		foreach($this->orderBy as $order) {
52
+		foreach ($this->orderBy as $order) {
53 53
 			list($expression, $direction) = $order;
54 54
 			$arr[] = sprintf("\t%s %s", $expression, strtoupper($direction));
55 55
 		}
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	private function addOrder($expression, $direction) {
64 64
 		$direction = $this->fixDirection($direction);
65
-		if(is_array($expression)) {
66
-			if(!count($expression)) {
65
+		if (is_array($expression)) {
66
+			if (!count($expression)) {
67 67
 				return;
68 68
 			}
69 69
 			$arguments = [
Please login to merge, or discard this patch.
src/Builder/Traits/JoinBuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,15 +47,15 @@
 block discarded – undo
47 47
 	 */
48 48
 	protected function buildJoins($query) {
49 49
 		$arr = [];
50
-		foreach($this->joinTables as $table) {
50
+		foreach ($this->joinTables as $table) {
51 51
 			$join = $table['type']." JOIN\n";
52
-			$join .= "\t" . $this->buildTableName($table['alias'], $table['name']);
53
-			if($table['expression']) {
54
-				$join .= " ON " . $this->db()->quoteExpression($table['expression'], $table['arguments']);
52
+			$join .= "\t".$this->buildTableName($table['alias'], $table['name']);
53
+			if ($table['expression']) {
54
+				$join .= " ON ".$this->db()->quoteExpression($table['expression'], $table['arguments']);
55 55
 			}
56 56
 			$arr[] = $join;
57 57
 		}
58
-		if(count($arr)) {
58
+		if (count($arr)) {
59 59
 			$query .= join("\n", $arr)."\n";
60 60
 		}
61 61
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Traits/TableBuilder.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	 * @return $this
14 14
 	 */
15 15
 	protected function addTable($alias, $table = null) {
16
-		if($table === null) {
16
+		if ($table === null) {
17 17
 			list($alias, $table) = [$table, $alias];
18 18
 		}
19 19
 		$this->tables[] = ['alias' => $alias, 'name' => $table];
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	protected function buildTables($query) {
28 28
 		$arr = [];
29
-		foreach($this->tables as $table) {
29
+		foreach ($this->tables as $table) {
30 30
 			$arr[] = "\t".$this->buildTableName($table['alias'], $table['name']);
31 31
 		}
32
-		if(count($arr)) {
32
+		if (count($arr)) {
33 33
 			$query .= join(",\n", $arr)."\n";
34 34
 		}
35 35
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Traits/GroupByBuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 	 * @return $this
12 12
 	 */
13 13
 	public function groupBy() {
14
-		foreach(func_get_args() as $expression) {
15
-			if(is_array($expression)) {
16
-				if(!count($expression)) {
14
+		foreach (func_get_args() as $expression) {
15
+			if (is_array($expression)) {
16
+				if (!count($expression)) {
17 17
 					continue;
18 18
 				}
19 19
 				$arguments = [
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 	 * @return string
33 33
 	 */
34 34
 	protected function buildGroups($query) {
35
-		if(!count($this->groupBy)) {
35
+		if (!count($this->groupBy)) {
36 36
 			return $query;
37 37
 		}
38 38
 		$query .= "GROUP BY\n";
39 39
 		$arr = [];
40
-		foreach($this->groupBy as $expression) {
40
+		foreach ($this->groupBy as $expression) {
41 41
 			$arr[] = "\t{$expression}";
42 42
 		}
43 43
 		return $query.join(",\n", $arr)."\n";
Please login to merge, or discard this patch.
src/Builder/Helpers/FieldTypeProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	 */
11 11
 	public static function getFieldTypes(QueryStatement $statement) {
12 12
 		$fieldTypes = [];
13
-		for($i = 0; $column = $statement->getColumnMeta($i); $i++) {
13
+		for ($i = 0; $column = $statement->getColumnMeta($i); $i++) {
14 14
 			$fieldTypes[$column['name']] = self::getTypeFromNativeType($column['native_type']);
15 15
 		}
16 16
 		return $fieldTypes;
Please login to merge, or discard this patch.
src/Builder/Internal/DDLRunnable.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	public function run(array $params = []) {
26 26
 		$this->query->execute($params);
27 27
 		$response = $this->query->getStatement()->rowCount();
28
-		if($this->callbackFn !== null) {
28
+		if ($this->callbackFn !== null) {
29 29
 			$response = call_user_func($this->callbackFn, $response);
30 30
 		}
31 31
 		return $response;
Please login to merge, or discard this patch.
src/Builder/Insert.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return $this
90 90
 	 */
91 91
 	public function addExpr($str, $_ = null) {
92
-		if(count(func_get_args()) > 1) {
92
+		if (count(func_get_args()) > 1) {
93 93
 			$this->fields[] = func_get_args();
94 94
 		} else {
95 95
 			$this->fields[] = $str;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return $this
104 104
 	 */
105 105
 	public function updateExpr($str, $_ = null) {
106
-		if(count(func_get_args()) > 1) {
106
+		if (count(func_get_args()) > 1) {
107 107
 			$this->update[] = func_get_args();
108 108
 		} else {
109 109
 			$this->update[] = $str;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * @return $this
117 117
 	 */
118 118
 	public function addOrUpdateExpr($str) {
119
-		if(count(func_get_args()) > 1) {
119
+		if (count(func_get_args()) > 1) {
120 120
 			$this->fields[] = func_get_args();
121 121
 			$this->update[] = func_get_args();
122 122
 		} else {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return $this
134 134
 	 */
135 135
 	public function addAll(array $data, array $mask = null, array $excludeFields = null) {
136
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
136
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
137 137
 			$this->add($field, $value);
138 138
 		});
139 139
 		return $this;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @return $this
147 147
 	 */
148 148
 	public function updateAll(array $data, array $mask = null, array $excludeFields = null) {
149
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
149
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
150 150
 			if ($field !== $this->keyField) {
151 151
 				$this->update($field, $value);
152 152
 			}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$ignoreStr = $this->ignore ? ' IGNORE' : '';
191 191
 		$queryArr[] = "INSERT{$ignoreStr} INTO\n\t{$tableName}\n";
192 192
 
193
-		if($this->from !== null) {
193
+		if ($this->from !== null) {
194 194
 			$fields = $this->from->getFields();
195 195
 			$queryArr[] = sprintf("\t(%s)\n", join(', ', array_keys($fields)));
196 196
 			$queryArr[] = $this->from;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		}
205 205
 
206 206
 		$updateData = $this->buildUpdate();
207
-		if($updateData) {
207
+		if ($updateData) {
208 208
 			$queryArr[] = "{$updateData}\n";
209 209
 		}
210 210
 
@@ -237,12 +237,12 @@  discard block
 block discarded – undo
237 237
 	 * @return $this
238 238
 	 */
239 239
 	private function addAllTo(array $data, array $mask = null, array $excludeFields = null, $fn) {
240
-		if($mask !== null) {
240
+		if ($mask !== null) {
241 241
 			$data = array_intersect_key($data, array_combine($mask, $mask));
242 242
 		}
243
-		if($excludeFields !== null) {
244
-			foreach($excludeFields as $excludeField) {
245
-				if(array_key_exists($excludeField, $data)) {
243
+		if ($excludeFields !== null) {
244
+			foreach ($excludeFields as $excludeField) {
245
+				if (array_key_exists($excludeField, $data)) {
246 246
 					unset($data[$excludeField]);
247 247
 				}
248 248
 			}
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 */
260 260
 	private function buildUpdate() {
261 261
 		$queryArr = [];
262
-		if(!empty($this->update)) {
262
+		if (!empty($this->update)) {
263 263
 			$queryArr[] = "ON DUPLICATE KEY UPDATE\n";
264 264
 			$updateArr = [];
265
-			if($this->keyField !== null) {
265
+			if ($this->keyField !== null) {
266 266
 				$updateArr[] = "\t`{$this->keyField}` = LAST_INSERT_ID({$this->keyField})";
267 267
 			}
268 268
 			$updateArr = $this->buildFieldList($this->update, $updateArr);
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @return array
286 286
 	 */
287 287
 	private function clearValues(array $values) {
288
-		if(!count($values)) {
288
+		if (!count($values)) {
289 289
 			return [];
290 290
 		}
291 291
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		$result = [];
295 295
 
296 296
 		foreach ($values as $fieldName => $fieldValue) {
297
-			if(in_array($fieldName, $fields)) {
297
+			if (in_array($fieldName, $fields)) {
298 298
 				$result[$fieldName] = $fieldValue;
299 299
 			}
300 300
 		}
Please login to merge, or discard this patch.