Passed
Push — master ( 16ffdb...34016b )
by Ron
02:28
created
src/Builder/Update.php 1 patch
Spacing   +13 added lines, -13 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 table(string $alias, $table = null): self {
32
-		if($table === null) {
32
+		if ($table === null) {
33 33
 			[$alias, $table] = [$table, $alias];
34 34
 		}
35 35
 		$this->addTable($alias, $table);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @return $this
65 65
 	 */
66 66
 	public function setExpr(string $expr, ...$args): self {
67
-		if(count($args) > 0) {
67
+		if (count($args) > 0) {
68 68
 			$this->fields[] = func_get_args();
69 69
 		} else {
70 70
 			$this->fields[] = $expr;
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 * @return $this
79 79
 	 */
80 80
 	public function setAll(array $data, array $allowedFields = null): self {
81
-		if($allowedFields !== null) {
82
-			foreach($data as $fieldName => $value) {
83
-				if(in_array($fieldName, $allowedFields)) {
81
+		if ($allowedFields !== null) {
82
+			foreach ($data as $fieldName => $value) {
83
+				if (in_array($fieldName, $allowedFields)) {
84 84
 					$this->set($fieldName, $value);
85 85
 				}
86 86
 			}
87 87
 		} else {
88 88
 			$values = $this->clearValues($data);
89
-			foreach($values as $fieldName => $value) {
89
+			foreach ($values as $fieldName => $value) {
90 90
 				$this->set($fieldName, $value);
91 91
 			}
92 92
 		}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	private function buildAssignments(string $query): string {
123 123
 		$sqlFields = $this->buildFieldList($this->fields);
124
-		if(!count($sqlFields)) {
124
+		if (!count($sqlFields)) {
125 125
 			throw new RuntimeException('No field-data found');
126 126
 		}
127 127
 		return sprintf("%s%s\n", $query, implode(",\n", $sqlFields));
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 	 * @return array<string, mixed>
133 133
 	 */
134 134
 	private function clearValues(array $values): array {
135
-		if(!count($values)) {
135
+		if (!count($values)) {
136 136
 			return [];
137 137
 		}
138 138
 		$tables = $this->getTables();
139
-		if(!count($tables)) {
139
+		if (!count($tables)) {
140 140
 			throw new RuntimeException('Table name is missing');
141 141
 		}
142
-		if(count($tables) > 1) {
142
+		if (count($tables) > 1) {
143 143
 			throw new RuntimeException('Batch values only work with max. one table');
144 144
 		}
145 145
 
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 		$tableName = $table['name'];
148 148
 
149 149
 		$result = [];
150
-		if(is_string($tableName)) {
150
+		if (is_string($tableName)) {
151 151
 			$fields = $this->db()->getTableFields($tableName);
152 152
 
153
-			foreach($values as $fieldName => $fieldValue) {
154
-				if(in_array($fieldName, $fields, true)) {
153
+			foreach ($values as $fieldName => $fieldValue) {
154
+				if (in_array($fieldName, $fields, true)) {
155 155
 					$result[$fieldName] = $fieldValue;
156 156
 				}
157 157
 			}
Please login to merge, or discard this patch.
src/Builder/Statement.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@
 block discarded – undo
29 29
 	 * @return $this
30 30
 	 */
31 31
 	public function debug($stop = true) {
32
-		if(array_key_exists('debug_formatter', $this->options)) {
32
+		if (array_key_exists('debug_formatter', $this->options)) {
33 33
 			$this->options['debug_formatter']();
34
-		} elseif(PHP_SAPI === 'cli') {
34
+		} elseif (PHP_SAPI === 'cli') {
35 35
 			echo "\n{$this->__toString()}\n";
36 36
 		} else {
37 37
 			echo "<pre>{$this->__toString()}</pre>";
38 38
 		}
39
-		if($stop) {
39
+		if ($stop) {
40 40
 			exit;
41 41
 		}
42 42
 		return $this;
Please login to merge, or discard this patch.
src/Databases/MySQL/MySQLSelect.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
 	 * @return $this
126 126
 	 */
127 127
 	public function from(?string $alias, $table = null) {
128
-		if($table === null) {
128
+		if ($table === null) {
129 129
 			[$alias, $table] = [$table, $alias];
130 130
 			$this->addTable($alias, (string) $table);
131 131
 		} else {
Please login to merge, or discard this patch.
src/Builder/Traits/HavingBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 	 * @return $this
20 20
 	 */
21 21
 	public function having($expression, ...$args) {
22
-		$fn = function ($expression, $args) { $this->having[] = [$expression, $args]; };
22
+		$fn = function($expression, $args) { $this->having[] = [$expression, $args]; };
23 23
 		ConditionAddHelper::addCondition($fn, $expression, $args);
24 24
 		return $this;
25 25
 	}
Please login to merge, or discard this patch.
src/Builder/Traits/WhereBuilder.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 	 * @return $this
20 20
 	 */
21 21
 	public function where($expression, ...$args) {
22
-		$fn = function ($expression, $args) { $this->where[] = [$expression, $args]; };
22
+		$fn = function($expression, $args) { $this->where[] = [$expression, $args]; };
23 23
 		ConditionAddHelper::addCondition($fn, $expression, $args);
24 24
 		return $this;
25 25
 	}
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 [$expression, $direction]) {
52
+		foreach ($this->orderBy as [$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): void {
63 63
 		$direction = $this->fixDirection($direction);
64
-		if(is_array($expression)) {
65
-			if(count($expression) < 1) {
64
+		if (is_array($expression)) {
65
+			if (count($expression) < 1) {
66 66
 				return;
67 67
 			}
68 68
 			$expr = (string) $expression[0];
Please login to merge, or discard this patch.
src/Databases/MySQL/MySQLFieldQuoter.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
 	 * @return string
10 10
 	 */
11 11
 	public static function quoteField(string $field): string {
12
-		if(is_numeric($field) || !is_string($field)) {
12
+		if (is_numeric($field) || !is_string($field)) {
13 13
 			throw new UnexpectedValueException('Field name is invalid');
14 14
 		}
15
-		if(strpos($field, '`') !== false) {
15
+		if (strpos($field, '`') !== false) {
16 16
 			return $field;
17 17
 		}
18 18
 		$parts = explode('.', $field);
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprOrderBySpec.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	public function __construct(array $spec, array $sortFieldsSpec) {
16 16
 		$expressions = [];
17
-		foreach($spec as $specReference => $dbExpr) {
18
-			if(is_int($specReference)) {
17
+		foreach ($spec as $specReference => $dbExpr) {
18
+			if (is_int($specReference)) {
19 19
 				$specReference = $dbExpr;
20 20
 			}
21 21
 			$expressions[$specReference] = $dbExpr;
22 22
 		}
23
-		foreach($sortFieldsSpec as $sortFieldSpec) {
24
-			if(array_key_exists(0, $sortFieldSpec)) {
25
-				if(array_key_exists($sortFieldSpec[0], $expressions)) {
23
+		foreach ($sortFieldsSpec as $sortFieldSpec) {
24
+			if (array_key_exists(0, $sortFieldSpec)) {
25
+				if (array_key_exists($sortFieldSpec[0], $expressions)) {
26 26
 					$direction = 'ASC';
27
-					if(array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') {
27
+					if (array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') {
28 28
 						$direction = 'DESC';
29 29
 					}
30 30
 					$this->fields[] = [
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 					];
34 34
 				}
35 35
 			} else { // @phpstan-ignore-line
36
-				foreach($sortFieldSpec as $alias => $direction) {
36
+				foreach ($sortFieldSpec as $alias => $direction) {
37 37
 					$direction = strtoupper($direction) === 'DESC' ? 'DESC' : 'ASC';
38
-					if(array_key_exists($alias, $expressions)) {
38
+					if (array_key_exists($alias, $expressions)) {
39 39
 						$this->fields[] = [$expressions[$alias], $direction];
40 40
 					}
41 41
 				}
Please login to merge, or discard this patch.
src/Builder/Expr/RequiredDBFilterMap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	 * @return DBExprFilter
37 37
 	 */
38 38
 	public function __invoke(string $expression, $keyPath, $validator = null) {
39
-		if(!RecursiveStructureAccess::recursiveHas($this->map, $keyPath)) {
39
+		if (!RecursiveStructureAccess::recursiveHas($this->map, $keyPath)) {
40 40
 			throw new RequiredValueNotFoundException(sprintf("Required value %s not found", json_encode($keyPath, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)));
41 41
 		}
42 42
 		return new DBExprFilter($expression, $this->map, $keyPath, $validator);
Please login to merge, or discard this patch.