Passed
Push — master ( 81361e...ca0b43 )
by Ron
02:20
created
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): array {
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/Traits/TableNameBuilder.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -13,34 +13,34 @@
 block discarded – undo
13 13
 	 * @return string
14 14
 	 */
15 15
 	protected function buildTableName(?string $alias, $name): string {
16
-		if(is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) {
16
+		if (is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) {
17 17
 			$name = (string) $name;
18 18
 			$lines = explode("\n", $name);
19
-			$lines = array_map(static function (string $line) { return "\t{$line}"; }, $lines);
19
+			$lines = array_map(static function(string $line) { return "\t{$line}"; }, $lines);
20 20
 			$name = implode("\n", $lines);
21
-			$name = '(' . trim(rtrim(trim($name), ';')) . ')';
21
+			$name = '('.trim(rtrim(trim($name), ';')).')';
22 22
 		}
23
-		if(is_array($name)) {
23
+		if (is_array($name)) {
24 24
 			$parts = [];
25
-			foreach($name as $index => $bucket) {
26
-				if(is_scalar($bucket) && ctype_digit((string) $index)) {
25
+			foreach ($name as $index => $bucket) {
26
+				if (is_scalar($bucket) && ctype_digit((string) $index)) {
27 27
 					$parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}";
28 28
 				} else {
29 29
 					$values = [];
30
-					foreach($bucket as $field => $value) {
30
+					foreach ($bucket as $field => $value) {
31 31
 						$values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field));
32 32
 					}
33 33
 					$parts[] = sprintf("SELECT %s", implode(', ', $values));
34 34
 				}
35 35
 			}
36
-			$name = '(' . implode("\n\tUNION\n\t", $parts) . ')';
36
+			$name = '('.implode("\n\tUNION\n\t", $parts).')';
37 37
 		}
38
-		if($this->db()->getVirtualTables()->has($name)) {
38
+		if ($this->db()->getVirtualTables()->has($name)) {
39 39
 			$select = (string) $this->db()->getVirtualTables()->get($name);
40 40
 			$name = sprintf('(%s)', implode("\n\t", explode("\n", trim($select))));
41 41
 		}
42 42
 		$name = $this->aliasReplacer()->replace($name);
43
-		if($alias !== null) {
43
+		if ($alias !== null) {
44 44
 			return sprintf("%s %s", $name, $alias);
45 45
 		}
46 46
 		return $name;
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(string $query): string {
51 51
 		$arr = [];
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 .= implode("\n", $arr)."\n";
62 62
 		}
63 63
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Traits/LimitBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@
 block discarded – undo
28 28
 	 */
29 29
 	protected function buildLimit(string $query, ?int $offset = null) {
30 30
 		$limit = $this->limit;
31
-		if($limit === null && $offset !== null) {
31
+		if ($limit === null && $offset !== null) {
32 32
 			$limit = '18446744073709551615';
33 33
 		}
34
-		if($limit !== null) {
34
+		if ($limit !== null) {
35 35
 			$query .= "LIMIT\n\t{$limit}\n";
36 36
 		}
37 37
 		return $query;
Please login to merge, or discard this patch.
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, string $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(string $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), implode("\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(string $query): string {
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 list($expression, $direction)) {
52
+		foreach ($this->orderBy as list($expression, $direction)) {
53 53
 			$arr[] = sprintf("\t%s %s", $expression, strtoupper($direction));
54 54
 		}
55 55
 		return $query.implode(",\n", $arr)."\n";
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	private function addOrder($expression, string $direction) {
63 63
 		$direction = $this->fixDirection($direction);
64
-		if(is_array($expression)) {
65
-			if(!count($expression)) {
64
+		if (is_array($expression)) {
65
+			if (!count($expression)) {
66 66
 				return;
67 67
 			}
68 68
 			$arguments = [
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[] = ['alias' => $alias, 'name' => $table];
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected function buildTables(string $query): string {
30 30
 		$arr = [];
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 .= implode(",\n", $arr)."\n";
36 36
 		}
37 37
 		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
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 	 * @return $this
13 13
 	 */
14 14
 	public function groupBy(...$args) {
15
-		foreach($args as $expression) {
16
-			if(is_array($expression)) {
17
-				if(!count($expression)) {
15
+		foreach ($args as $expression) {
16
+			if (is_array($expression)) {
17
+				if (!count($expression)) {
18 18
 					continue;
19 19
 				}
20 20
 				$arguments = [
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 * @return string
34 34
 	 */
35 35
 	protected function buildGroups(string $query): string {
36
-		if(!count($this->groupBy)) {
36
+		if (!count($this->groupBy)) {
37 37
 			return $query;
38 38
 		}
39 39
 		$query .= "GROUP BY\n";
40 40
 		$arr = [];
41
-		foreach($this->groupBy as $expression) {
41
+		foreach ($this->groupBy as $expression) {
42 42
 			$arr[] = "\t{$expression}";
43 43
 		}
44 44
 		return $query.implode(",\n", $arr)."\n";
Please login to merge, or discard this patch.
src/Builder/Traits/OffsetBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	 * @return string
27 27
 	 */
28 28
 	protected function buildOffset(string $query): string {
29
-		if($this->offset !== null) {
29
+		if ($this->offset !== null) {
30 30
 			$query .= "OFFSET\n\t{$this->offset}\n";
31 31
 		}
32 32
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Traits/UnionBuilder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	 * @return $this
15 15
 	 */
16 16
 	public function union(...$queries) {
17
-		foreach($queries as $query) {
17
+		foreach ($queries as $query) {
18 18
 			$this->unions[] = ['', $query];
19 19
 		}
20 20
 		return $this;
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @return $this
26 26
 	 */
27 27
 	public function unionAll(...$queries) {
28
-		foreach($queries as $query) {
28
+		foreach ($queries as $query) {
29 29
 			$this->unions[] = ['ALL', $query];
30 30
 		}
31 31
 		return $this;
@@ -36,21 +36,21 @@  discard block
 block discarded – undo
36 36
 	 * @return string
37 37
 	 */
38 38
 	protected function buildUnions(string $query): string {
39
-		$wrap = static function ($query) {
39
+		$wrap = static function($query) {
40 40
 			$query = trim($query);
41 41
 			$query = implode("\n\t", explode("\n", $query));
42 42
 			return sprintf("(\n\t%s\n)", $query);
43 43
 		};
44 44
 		$queries = [$wrap($query)];
45
-		foreach($this->unions as $unionQuery) {
46
-			if($unionQuery[0] === 'ALL') {
45
+		foreach ($this->unions as $unionQuery) {
46
+			if ($unionQuery[0] === 'ALL') {
47 47
 				$queries[] = 'UNION ALL';
48 48
 			} else {
49 49
 				$queries[] = 'UNION';
50 50
 			}
51 51
 			$queries[] = $wrap($unionQuery[1]);
52 52
 		}
53
-		if(count($queries) > 1) {
53
+		if (count($queries) > 1) {
54 54
 			return implode(' ', $queries);
55 55
 		}
56 56
 		return $query;
Please login to merge, or discard this patch.