Completed
Push — master ( 792038...9ff9da )
by Ron
02:22
created
src/Builder/Traits/OffsetBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 	 * @return string
22 22
 	 */
23 23
 	protected function buildOffset($query) {
24
-		if($this->offset !== null) {
24
+		if ($this->offset !== null) {
25 25
 			$query .= "OFFSET\n\t{$this->offset}\n";
26 26
 		}
27 27
 		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
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 	 * @return $this
14 14
 	 */
15 15
 	public function groupBy() {
16
-		foreach(func_get_args() as $expression) {
17
-			if(is_array($expression)) {
18
-				if(!count($expression)) {
16
+		foreach (func_get_args() as $expression) {
17
+			if (is_array($expression)) {
18
+				if (!count($expression)) {
19 19
 					continue;
20 20
 				}
21 21
 				$arguments = array(
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	 * @return string
35 35
 	 */
36 36
 	protected function buildGroups($query) {
37
-		if(!count($this->groupBy)) {
37
+		if (!count($this->groupBy)) {
38 38
 			return $query;
39 39
 		}
40 40
 		$query .= "GROUP BY\n";
41 41
 		$arr = array();
42
-		foreach($this->groupBy as $expression) {
42
+		foreach ($this->groupBy as $expression) {
43 43
 			$arr[] = "\t{$expression}";
44 44
 		}
45 45
 		return $query.join(",\n", $arr)."\n";
Please login to merge, or discard this patch.
src/Builder/Traits/UnionBuilder.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@
 block discarded – undo
30 30
 	 * @return string
31 31
 	 */
32 32
 	protected function buildUnions($query) {
33
-		$wrap = function ($query) {
33
+		$wrap = function($query) {
34 34
 			$query = trim($query);
35 35
 			$query = join("\n\t", explode("\n", $query));
36 36
 			return sprintf("(\n\t%s\n)", $query);
37 37
 		};
38 38
 		$queries = [$wrap($query)];
39
-		foreach($this->unions as $unionQuery) {
40
-			if($unionQuery[0] === 'ALL') {
39
+		foreach ($this->unions as $unionQuery) {
40
+			if ($unionQuery[0] === 'ALL') {
41 41
 				$queries[] = 'UNION ALL';
42 42
 			} else {
43 43
 				$queries[] = 'UNION';
44 44
 			}
45 45
 			$queries[] = $wrap($unionQuery[1]);
46 46
 		}
47
-		if(count($queries) > 1) {
47
+		if (count($queries) > 1) {
48 48
 			return join(" ", $queries);
49 49
 		}
50 50
 		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
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @return $this
16 16
 	 */
17 17
 	protected function addTable($alias, $table = null) {
18
-		if($table === null) {
18
+		if ($table === null) {
19 19
 			list($alias, $table) = [$table, $alias];
20 20
 		}
21 21
 		$this->tables[] = array('alias' => $alias, 'name' => $table);
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected function buildTables($query) {
30 30
 		$arr = array();
31
-		foreach($this->tables as $table) {
31
+		foreach ($this->tables as $table) {
32 32
 			$arr[] = "\t".$this->buildTableName($table['alias'], $table['name']);
33 33
 		}
34
-		if(count($arr)) {
34
+		if (count($arr)) {
35 35
 			$query .= join(",\n", $arr)."\n";
36 36
 		}
37 37
 		return $query;
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
@@ -49,15 +49,15 @@
 block discarded – undo
49 49
 	 */
50 50
 	protected function buildJoins($query) {
51 51
 		$arr = array();
52
-		foreach($this->joinTables as $table) {
52
+		foreach ($this->joinTables as $table) {
53 53
 			$join = $table['type']." JOIN\n";
54
-			$join .= "\t" . $this->buildTableName($table['alias'], $table['name']);
55
-			if($table['expression']) {
56
-				$join .= " ON " . $this->db()->quoteExpression($table['expression'], $table['arguments']);
54
+			$join .= "\t".$this->buildTableName($table['alias'], $table['name']);
55
+			if ($table['expression']) {
56
+				$join .= " ON ".$this->db()->quoteExpression($table['expression'], $table['arguments']);
57 57
 			}
58 58
 			$arr[] = $join;
59 59
 		}
60
-		if(count($arr)) {
60
+		if (count($arr)) {
61 61
 			$query .= join("\n", $arr)."\n";
62 62
 		}
63 63
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Delete.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return $this
30 30
 	 */
31 31
 	public function from($alias, $table = null) {
32
-		if($table !== null) {
32
+		if ($table !== null) {
33 33
 			$this->aliases[] = $alias;
34 34
 		}
35 35
 		$this->addTable($alias, $table);
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	public function __toString() {
44 44
 		$query = "DELETE ";
45 45
 		$query .= join(', ', $this->aliases);
46
-		$query = trim($query) . " FROM\n";
46
+		$query = trim($query)." FROM\n";
47 47
 		$query = $this->buildTables($query);
48 48
 		$query = $this->buildJoins($query);
49 49
 		$query = $this->buildWhereConditions($query);
Please login to merge, or discard this patch.
src/Builder/Helpers/FieldValueConverter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
 	 * @return array
9 9
 	 */
10 10
 	public static function convertValues(array $row, array $columnDefinitions) {
11
-		foreach($row as $key => &$value) {
12
-			if($value !== null) {
11
+		foreach ($row as $key => &$value) {
12
+			if ($value !== null) {
13 13
 				$value = self::convertValue($value, $columnDefinitions[$key]);
14 14
 			}
15 15
 		}
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 = array()) {
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
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @return $this
89 89
 	 */
90 90
 	public function addExpr($str) {
91
-		if(count(func_get_args()) > 1) {
91
+		if (count(func_get_args()) > 1) {
92 92
 			$this->fields[] = func_get_args();
93 93
 		} else {
94 94
 			$this->fields[] = $str;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @return $this
103 103
 	 */
104 104
 	public function updateExpr($str) {
105
-		if(count(func_get_args()) > 1) {
105
+		if (count(func_get_args()) > 1) {
106 106
 			$this->update[] = func_get_args();
107 107
 		} else {
108 108
 			$this->update[] = $str;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return $this
116 116
 	 */
117 117
 	public function addOrUpdateExpr($str) {
118
-		if(count(func_get_args()) > 1) {
118
+		if (count(func_get_args()) > 1) {
119 119
 			$this->fields[] = func_get_args();
120 120
 			$this->update[] = func_get_args();
121 121
 		} else {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @return $this
133 133
 	 */
134 134
 	public function addAll(array $data, array $mask = null, array $excludeFields = null) {
135
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
135
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
136 136
 			$this->add($field, $value);
137 137
 		});
138 138
 		return $this;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return $this
146 146
 	 */
147 147
 	public function updateAll(array $data, array $mask = null, array $excludeFields = null) {
148
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
148
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
149 149
 			if ($field !== $this->keyField) {
150 150
 				$this->update($field, $value);
151 151
 			}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		$ignoreStr = $this->ignore ? ' IGNORE' : '';
190 190
 		$queryArr[] = "INSERT{$ignoreStr} INTO\n\t{$tableName}\n";
191 191
 
192
-		if($this->from !== null) {
192
+		if ($this->from !== null) {
193 193
 			$fields = $this->from->getFields();
194 194
 			$queryArr[] = sprintf("\t(%s)\n", join(', ', array_keys($fields)));
195 195
 			$queryArr[] = $this->from;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		$updateData = $this->buildUpdate();
206
-		if($updateData) {
206
+		if ($updateData) {
207 207
 			$queryArr[] = "{$updateData}\n";
208 208
 		}
209 209
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 	 * @return $this
237 237
 	 */
238 238
 	private function addAllTo(array $data, array $mask = null, array $excludeFields = null, $fn) {
239
-		if($mask !== null) {
239
+		if ($mask !== null) {
240 240
 			$data = array_intersect_key($data, array_combine($mask, $mask));
241 241
 		}
242
-		if($excludeFields !== null) {
243
-			foreach($excludeFields as $excludeField) {
244
-				if(array_key_exists($excludeField, $data)) {
242
+		if ($excludeFields !== null) {
243
+			foreach ($excludeFields as $excludeField) {
244
+				if (array_key_exists($excludeField, $data)) {
245 245
 					unset($data[$excludeField]);
246 246
 				}
247 247
 			}
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 	 */
258 258
 	private function buildUpdate() {
259 259
 		$queryArr = array();
260
-		if(!empty($this->update)) {
260
+		if (!empty($this->update)) {
261 261
 			$queryArr[] = "ON DUPLICATE KEY UPDATE\n";
262 262
 			$updateArr = array();
263
-			if($this->keyField !== null) {
263
+			if ($this->keyField !== null) {
264 264
 				$updateArr[] = "\t`{$this->keyField}` = LAST_INSERT_ID({$this->keyField})";
265 265
 			}
266 266
 			$updateArr = $this->buildFieldList($this->update, $updateArr);
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @throws Exception
285 285
 	 */
286 286
 	private function clearValues(array $values) {
287
-		if(!count($values)) {
287
+		if (!count($values)) {
288 288
 			return [];
289 289
 		}
290 290
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		$result = array();
294 294
 
295 295
 		foreach ($values as $fieldName => $fieldValue) {
296
-			if(in_array($fieldName, $fields)) {
296
+			if (in_array($fieldName, $fields)) {
297 297
 				$result[$fieldName] = $fieldValue;
298 298
 			}
299 299
 		}
Please login to merge, or discard this patch.