Completed
Push — master ( 0585ed...9ed34e )
by Ron
02:14 queued 17s
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/Databases/MySQL.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -261,7 +261,7 @@
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	/**
264
-	 * @param int|callable $tries
264
+	 * @param integer $tries
265 265
 	 * @param callable|null $callback
266 266
 	 * @return mixed
267 267
 	 * @throws \Exception
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param array $options
42 42
 	 */
43 43
 	public function __construct(PDO $pdo, array $options = []) {
44
-		if($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
44
+		if ($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
45 45
 			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
46 46
 		}
47 47
 		$this->pdo = $pdo;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @return VirtualTables
76 76
 	 */
77 77
 	public function getVirtualTables() {
78
-		if($this->virtualTables === null) {
78
+		if ($this->virtualTables === null) {
79 79
 			$this->virtualTables = new VirtualTables();
80 80
 		}
81 81
 		return $this->virtualTables;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return QueryStatement
88 88
 	 */
89 89
 	public function query($query) {
90
-		return $this->buildQueryStatement($query, function ($query) {
90
+		return $this->buildQueryStatement($query, function($query) {
91 91
 			$stmt = $this->pdo->query($query);
92 92
 			return $stmt;
93 93
 		});
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @return QueryStatement
100 100
 	 */
101 101
 	public function prepare($query) {
102
-		return $this->buildQueryStatement((string) $query, function ($query) {
102
+		return $this->buildQueryStatement((string) $query, function($query) {
103 103
 			$stmt = $this->pdo->prepare($query);
104 104
 			return $stmt;
105 105
 		});
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return int
112 112
 	 */
113 113
 	public function exec($query, array $params = array()) {
114
-		return $this->exceptionHandler(function () use ($query, $params) {
114
+		return $this->exceptionHandler(function() use ($query, $params) {
115 115
 			$stmt = $this->pdo->prepare($query);
116 116
 			$timer = microtime(true);
117 117
 			$stmt->execute($params);
118
-			$this->queryLoggers->log($query, microtime(true) - $timer);
118
+			$this->queryLoggers->log($query, microtime(true)-$timer);
119 119
 			$result = $stmt->rowCount();
120 120
 			$stmt->closeCursor();
121 121
 			return $result;
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function getTableFields($table) {
137 137
 		$table = $this->select()->aliasReplacer()->replace($table);
138
-		if(array_key_exists($table, self::$tableFields)) {
138
+		if (array_key_exists($table, self::$tableFields)) {
139 139
 			return self::$tableFields[$table];
140 140
 		}
141 141
 		$stmt = $this->pdo->query("DESCRIBE {$table}");
142 142
 		$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
143
-		self::$tableFields[$table] = array_map(function ($row) { return $row['Field']; }, $rows);
143
+		self::$tableFields[$table] = array_map(function($row) { return $row['Field']; }, $rows);
144 144
 		$stmt->closeCursor();
145 145
 		return self::$tableFields[$table];
146 146
 	}
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 	 * @return string
152 152
 	 */
153 153
 	public function quoteExpression($expression, array $arguments = array()) {
154
-		$func = function () use ($arguments) {
154
+		$func = function() use ($arguments) {
155 155
 			static $idx = -1;
156 156
 			$idx++;
157 157
 			$index = $idx;
158
-			if(array_key_exists($index, $arguments)) {
158
+			if (array_key_exists($index, $arguments)) {
159 159
 				$argument = $arguments[$index];
160 160
 				$value = $this->quote($argument);
161 161
 			} else {
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	 * @return string
173 173
 	 */
174 174
 	public function quote($value) {
175
-		if(is_null($value)) {
175
+		if (is_null($value)) {
176 176
 			$result = 'NULL';
177
-		} elseif($value instanceof Builder\DBExpr) {
177
+		} elseif ($value instanceof Builder\DBExpr) {
178 178
 			$result = $value->getExpression();
179
-		} elseif($value instanceof Builder\Select) {
179
+		} elseif ($value instanceof Builder\Select) {
180 180
 			$result = sprintf('(%s)', (string) $value);
181
-		} elseif(is_array($value)) {
182
-			$result = join(', ', array_map(function ($value) { return $this->quote($value); }, $value));
181
+		} elseif (is_array($value)) {
182
+			$result = join(', ', array_map(function($value) { return $this->quote($value); }, $value));
183 183
 		} else {
184 184
 			$result = $this->pdo->quote($value);
185 185
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		if (is_numeric($field) || !is_string($field)) {
195 195
 			throw new UnexpectedValueException('Field name is invalid');
196 196
 		}
197
-		if(strpos($field, '`') !== false) {
197
+		if (strpos($field, '`') !== false) {
198 198
 			return (string) $field;
199 199
 		}
200 200
 		$parts = explode('.', $field);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		$select = array_key_exists('select-factory', $this->options)
210 210
 			? call_user_func($this->options['select-factory'], $this, $this->options['select-options'])
211 211
 			: new Builder\RunnableSelect($this, $this->options['select-options']);
212
-		if($fields !== null) {
212
+		if ($fields !== null) {
213 213
 			$select->fields($fields);
214 214
 		}
215 215
 		return $select;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		$insert = array_key_exists('insert-factory', $this->options)
224 224
 			? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options'])
225 225
 			: new Builder\RunnableInsert($this, $this->options['insert-options']);
226
-		if($fields !== null) {
226
+		if ($fields !== null) {
227 227
 			$insert->addAll($fields);
228 228
 		}
229 229
 		return $insert;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		$update = array_key_exists('update-factory', $this->options)
238 238
 			? call_user_func($this->options['update-factory'], $this, $this->options['update-options'])
239 239
 			: new Builder\RunnableUpdate($this, $this->options['update-options']);
240
-		if($fields !== null) {
240
+		if ($fields !== null) {
241 241
 			$update->setAll($fields);
242 242
 		}
243 243
 		return $update;
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 * @return $this
257 257
 	 */
258 258
 	public function transactionStart() {
259
-		if((int) $this->transactionLevel === 0) {
260
-			if($this->pdo->inTransaction()) {
259
+		if ((int) $this->transactionLevel === 0) {
260
+			if ($this->pdo->inTransaction()) {
261 261
 				$this->outerTransaction = true;
262 262
 			} else {
263 263
 				$this->pdo->beginTransaction();
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @throws \Exception
273 273
 	 */
274 274
 	public function transactionCommit() {
275
-		return $this->transactionEnd(function () {
275
+		return $this->transactionEnd(function() {
276 276
 			$this->pdo->commit();
277 277
 		});
278 278
 	}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @throws \Exception
283 283
 	 */
284 284
 	public function transactionRollback() {
285
-		return $this->transactionEnd(function () {
285
+		return $this->transactionEnd(function() {
286 286
 			$this->pdo->rollBack();
287 287
 		});
288 288
 	}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	public function dryRun($callback = null) {
297 297
 		$result = null;
298
-		if(!$this->pdo->inTransaction()) {
298
+		if (!$this->pdo->inTransaction()) {
299 299
 			$this->transactionStart();
300 300
 			try {
301 301
 				$result = call_user_func($callback, $this);
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 	 * @throws \Error
333 333
 	 */
334 334
 	public function transaction($tries = 1, $callback = null) {
335
-		if(is_callable($tries)) {
335
+		if (is_callable($tries)) {
336 336
 			$callback = $tries;
337 337
 			$tries = 1;
338
-		} elseif(!is_callable($callback)) {
338
+		} elseif (!is_callable($callback)) {
339 339
 			throw new RuntimeException('$callback must be a callable');
340 340
 		}
341 341
 		$result = null;
342 342
 		$exception = null;
343
-		for(; $tries--;) {
344
-			if(!$this->pdo->inTransaction()) {
343
+		for (; $tries--;) {
344
+			if (!$this->pdo->inTransaction()) {
345 345
 				$this->transactionStart();
346 346
 				try {
347 347
 					$result = call_user_func($callback, $this);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 				}
371 371
 			}
372 372
 		}
373
-		if($exception !== null) {
373
+		if ($exception !== null) {
374 374
 			throw $exception;
375 375
 		}
376 376
 		return $result;
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	private function transactionEnd($fn) {
385 385
 		$this->transactionLevel--;
386
-		if($this->transactionLevel < 0) {
386
+		if ($this->transactionLevel < 0) {
387 387
 			throw new RuntimeException("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction");
388 388
 		}
389
-		if((int) $this->transactionLevel === 0) {
390
-			if($this->outerTransaction) {
389
+		if ((int) $this->transactionLevel === 0) {
390
+			if ($this->outerTransaction) {
391 391
 				$this->outerTransaction = false;
392 392
 			} else {
393 393
 				call_user_func($fn);
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	private function buildQueryStatement($query, $fn) {
406 406
 		$stmt = call_user_func($fn, $query);
407
-		if(!$stmt) {
407
+		if (!$stmt) {
408 408
 			throw new RuntimeException("Could not execute statement:\n{$query}");
409 409
 		}
410 410
 		$stmtWrapper = new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers);
Please login to merge, or discard this patch.