Passed
Push — master ( 58ebbc...c2b78d )
by Ron
11:28
created
src/Builder/Insert.php 1 patch
Spacing   +21 added lines, -21 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(string $str, ...$args) {
92
-		if(count($args) > 0) {
92
+		if (count($args) > 0) {
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(string $str, ...$args) {
106
-		if(count($args) > 0) {
106
+		if (count($args) > 0) {
107 107
 			$this->update[] = func_get_args();
108 108
 		} else {
109 109
 			$this->update[] = $str;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @return $this
118 118
 	 */
119 119
 	public function addOrUpdateExpr(string $expr, ...$args) {
120
-		if(count($args) > 0) {
120
+		if (count($args) > 0) {
121 121
 			$this->fields[] = func_get_args();
122 122
 			$this->update[] = func_get_args();
123 123
 		} else {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @return $this
135 135
 	 */
136 136
 	public function addAll(array $data, ?array $mask = null, ?array $excludeFields = null) {
137
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
137
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
138 138
 			$this->add($field, $value);
139 139
 		});
140 140
 		return $this;
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 * @return $this
148 148
 	 */
149 149
 	public function updateAll(array $data, ?array $mask = null, ?array $excludeFields = null) {
150
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
151
-			if($field !== $this->keyField) {
150
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
151
+			if ($field !== $this->keyField) {
152 152
 				$this->update($field, $value);
153 153
 			}
154 154
 		});
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @return string
193 193
 	 */
194 194
 	public function __toString(): string {
195
-		if($this->table === null) {
195
+		if ($this->table === null) {
196 196
 			throw new RuntimeException('Specify a table-name');
197 197
 		}
198 198
 
@@ -202,21 +202,21 @@  discard block
 block discarded – undo
202 202
 		$ignoreStr = $this->ignore ? ' IGNORE' : '';
203 203
 		$queryArr[] = "INSERT{$ignoreStr} INTO\n\t{$tableName}\n";
204 204
 
205
-		if($this->from !== null) {
205
+		if ($this->from !== null) {
206 206
 			$fields = $this->from->getFields();
207 207
 			$queryArr[] = sprintf("\t(%s)\n", implode(', ', array_keys($fields)));
208 208
 			$queryArr[] = $this->from;
209 209
 		} else {
210 210
 			$fields = $this->fields;
211 211
 			$insertData = $this->buildFieldList($fields);
212
-			if(!count($insertData)) {
212
+			if (!count($insertData)) {
213 213
 				throw new RuntimeException('No field-data found');
214 214
 			}
215 215
 			$queryArr[] = sprintf("SET\n%s\n", implode(",\n", $insertData));
216 216
 		}
217 217
 
218 218
 		$updateData = $this->buildUpdate();
219
-		if($updateData) {
219
+		if ($updateData) {
220 220
 			$queryArr[] = "{$updateData}\n";
221 221
 		}
222 222
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return array<string|int, mixed>
231 231
 	 */
232 232
 	private function addTo(array $fields, string $field, $value): array {
233
-		if(!$this->isFieldNameValid($field)) {
233
+		if (!$this->isFieldNameValid($field)) {
234 234
 			throw new UnexpectedValueException('Field name is invalid');
235 235
 		}
236 236
 		$sqlField = $field;
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
 	 * @param callable(string, mixed): void $fn
247 247
 	 */
248 248
 	private function addAllTo(array $data, ?array $mask, ?array $excludeFields, $fn): void {
249
-		if($mask !== null) {
249
+		if ($mask !== null) {
250 250
 			$data = array_intersect_key($data, array_combine($mask, $mask));
251 251
 		}
252
-		if($excludeFields !== null) {
253
-			foreach($excludeFields as $excludeField) {
254
-				if(array_key_exists($excludeField, $data)) {
252
+		if ($excludeFields !== null) {
253
+			foreach ($excludeFields as $excludeField) {
254
+				if (array_key_exists($excludeField, $data)) {
255 255
 					unset($data[$excludeField]);
256 256
 				}
257 257
 			}
258 258
 		}
259 259
 		$data = $this->clearValues($data);
260
-		foreach($data as $field => $value) {
260
+		foreach ($data as $field => $value) {
261 261
 			$fn($field, $value);
262 262
 		}
263 263
 	}
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	private function buildUpdate(): string {
269 269
 		$queryArr = [];
270
-		if(!empty($this->update)) {
270
+		if (!empty($this->update)) {
271 271
 			$queryArr[] = "ON DUPLICATE KEY UPDATE\n";
272 272
 			$updateArr = [];
273
-			if($this->keyField !== null) {
273
+			if ($this->keyField !== null) {
274 274
 				$updateArr[] = "\t`{$this->keyField}` = LAST_INSERT_ID({$this->keyField})";
275 275
 			}
276 276
 			$updateArr = $this->buildFieldList($this->update, $updateArr);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @return array<string, mixed>
294 294
 	 */
295 295
 	private function clearValues(array $values): array {
296
-		if(!count($values)) {
296
+		if (!count($values)) {
297 297
 			return [];
298 298
 		}
299 299
 
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 		$fields = $this->db()->getTableFields($tableName);
302 302
 		$result = [];
303 303
 
304
-		foreach($values as $fieldName => $fieldValue) {
305
-			if(in_array($fieldName, $fields)) {
304
+		foreach ($values as $fieldName => $fieldValue) {
305
+			if (in_array($fieldName, $fields)) {
306 306
 				$result[$fieldName] = $fieldValue;
307 307
 			}
308 308
 		}
Please login to merge, or discard this patch.
src/Builder/Helpers/RecursiveStructureAccess.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 		if (!$count) {
29 29
 			return $default;
30 30
 		}
31
-		foreach($arrayPath as $idxValue) {
31
+		foreach ($arrayPath as $idxValue) {
32 32
 			$part = $idxValue;
33
-			if(!array_key_exists($part, $data)) {
33
+			if (!array_key_exists($part, $data)) {
34 34
 				return $default;
35 35
 			}
36 36
 			$data = $data[$part];
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	private static function _recursiveHas($structure, array $path): bool {
47 47
 		$data = self::ensureArrayIsArray($structure);
48
-		if($data === null) {
48
+		if ($data === null) {
49 49
 			return false;
50 50
 		}
51
-		if(!count($path)) {
51
+		if (!count($path)) {
52 52
 			return false;
53 53
 		}
54 54
 		$key = array_shift($path);
55
-		if(count($path)) {
55
+		if (count($path)) {
56 56
 			return self::_recursiveHas($data[$key] ?? null, $path);
57 57
 		}
58 58
 		return array_key_exists($key, $data);
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	 * @return string[]
64 64
 	 */
65 65
 	private static function getArrayPath($path): array {
66
-		if(is_array($path)) {
66
+		if (is_array($path)) {
67 67
 			return $path;
68 68
 		}
69 69
 		$parts = preg_split('{(?<!\\x5C)(?:\\x5C\\x5C)*\\.}', $path);
70
-		if($parts === false) {
70
+		if ($parts === false) {
71 71
 			return [$path];
72 72
 		}
73 73
 		return $parts;
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 	 * @return array<mixed, mixed>
79 79
 	 */
80 80
 	private static function ensureArrayIsArray($array): ?array {
81
-		if($array instanceof ArrayObject) {
81
+		if ($array instanceof ArrayObject) {
82 82
 			return $array->getArrayCopy();
83 83
 		}
84
-		if(is_object($array)) {
84
+		if (is_object($array)) {
85 85
 			return (array) $array;
86 86
 		}
87
-		if(is_array($array)) {
87
+		if (is_array($array)) {
88 88
 			return $array;
89 89
 		}
90 90
 		return null;
Please login to merge, or discard this patch.
src/Builder/Helpers/ConditionAddHelper.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 	 * @param array<DBParameterValueType> $args
17 17
 	 */
18 18
 	public static function addCondition(callable $addFn, $expression, array $args): void {
19
-		if($expression instanceof OptionalExpression) {
20
-			if($expression->isValid()) {
19
+		if ($expression instanceof OptionalExpression) {
20
+			if ($expression->isValid()) {
21 21
 				$addFn($expression->getExpression(), [$expression->getValue()]);
22 22
 			}
23
-		} elseif(is_object($expression)) {
23
+		} elseif (is_object($expression)) {
24 24
 			self::addAsArray($addFn, (array) $expression, $args);
25
-		} elseif(is_array($expression)) {
25
+		} elseif (is_array($expression)) {
26 26
 			self::addAsArray($addFn, $expression, $args);
27 27
 		} else {
28 28
 			$addFn($expression, $args);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param array<int, DBParameterValueType> $args
36 36
 	 */
37 37
 	private static function addAsArray(callable $addFn, array $expression, array $args): void {
38
-		if(count($expression) > 0) {
38
+		if (count($expression) > 0) {
39 39
 			$addFn($expression, $args);
40 40
 		}
41 41
 	}
Please login to merge, or discard this patch.
src/Builder/InsertUpdateStatement.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@
 block discarded – undo
34 34
 	 */
35 35
 	protected function buildFieldList(array $fields, array $query = []): array {
36 36
 		foreach ($fields as $fieldName => $fieldValue) {
37
-			if($fieldValue instanceof DefaultValue) {
37
+			if ($fieldValue instanceof DefaultValue) {
38 38
 				$fieldValue = 'DEFAULT';
39 39
 			}
40
-			if(is_array($this->mask) && !in_array($fieldName, $this->mask, true)) {
40
+			if (is_array($this->mask) && !in_array($fieldName, $this->mask, true)) {
41 41
 				continue;
42 42
 			}
43
-			if(is_int($fieldName)) {
43
+			if (is_int($fieldName)) {
44 44
 				if (is_array($fieldValue)) {
45 45
 					// @phpstan-ignore-next-line
46 46
 					$fieldValue = $this->db()->quoteExpression($fieldValue[0], array_slice($fieldValue, 1));
Please login to merge, or discard this patch.
src/Builder/Update.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @return $this
34 34
 	 */
35 35
 	public function table($alias, $table = null): self {
36
-		if($table === null) {
36
+		if ($table === null) {
37 37
 			[$alias, $table] = [$table, $alias];
38 38
 		}
39 39
 		$this->addTable($alias, $table);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return $this
69 69
 	 */
70 70
 	public function setExpr(string $expr, ...$args): self {
71
-		if(count($args) > 0) {
71
+		if (count($args) > 0) {
72 72
 			$this->fields[] = func_get_args();
73 73
 		} else {
74 74
 			$this->fields[] = $expr;
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 	 * @return $this
83 83
 	 */
84 84
 	public function setAll(array $data, ?array $allowedFields = null): self {
85
-		if($allowedFields !== null) {
86
-			foreach($data as $fieldName => $value) {
87
-				if(in_array($fieldName, $allowedFields)) {
85
+		if ($allowedFields !== null) {
86
+			foreach ($data as $fieldName => $value) {
87
+				if (in_array($fieldName, $allowedFields)) {
88 88
 					$this->set($fieldName, $value);
89 89
 				}
90 90
 			}
91 91
 		} else {
92 92
 			$values = $this->clearValues($data);
93
-			foreach($values as $fieldName => $value) {
93
+			foreach ($values as $fieldName => $value) {
94 94
 				$this->set($fieldName, $value);
95 95
 			}
96 96
 		}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	private function buildAssignments(string $query): string {
127 127
 		$sqlFields = $this->buildFieldList($this->fields);
128
-		if(!count($sqlFields)) {
128
+		if (!count($sqlFields)) {
129 129
 			throw new RuntimeException('No field-data found');
130 130
 		}
131 131
 		return sprintf("%s%s\n", $query, implode(",\n", $sqlFields));
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 	 * @return array<string, mixed>
137 137
 	 */
138 138
 	private function clearValues(array $values): array {
139
-		if(!count($values)) {
139
+		if (!count($values)) {
140 140
 			return [];
141 141
 		}
142 142
 		$tables = $this->getTables();
143
-		if(!count($tables)) {
143
+		if (!count($tables)) {
144 144
 			throw new RuntimeException('Table name is missing');
145 145
 		}
146
-		if(count($tables) > 1) {
146
+		if (count($tables) > 1) {
147 147
 			throw new RuntimeException('Batch values only work with max. one table');
148 148
 		}
149 149
 
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 		$tableName = $table['name'];
152 152
 
153 153
 		$result = [];
154
-		if(is_string($tableName)) {
154
+		if (is_string($tableName)) {
155 155
 			$fields = $this->db()->getTableFields($tableName);
156 156
 
157
-			foreach($values as $fieldName => $fieldValue) {
158
-				if(in_array($fieldName, $fields, true)) {
157
+			foreach ($values as $fieldName => $fieldValue) {
158
+				if (in_array($fieldName, $fields, true)) {
159 159
 					$result[$fieldName] = $fieldValue;
160 160
 				}
161 161
 			}
Please login to merge, or discard this patch.
src/Builder/Delete.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
 	 * @return $this
34 34
 	 */
35 35
 	public function from($alias, $table = null) {
36
-		if($table !== null) {
36
+		if ($table !== null) {
37 37
 			$this->aliases[] = $alias;
38 38
 		}
39
-		if($table === null) {
39
+		if ($table === null) {
40 40
 			[$alias, $table] = [$table, $alias];
41 41
 		}
42 42
 		$this->addTable($alias, $table);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	public function __toString(): string {
56 56
 		$query = 'DELETE ';
57 57
 		$query .= implode(', ', $this->aliases);
58
-		$query = trim($query) . " FROM\n";
58
+		$query = trim($query)." FROM\n";
59 59
 		$query = $this->buildTables($query);
60 60
 		$query = $this->buildJoins($query);
61 61
 		$query = $this->buildWhereConditions($query);
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
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
 	 * @return $this
124 124
 	 */
125 125
 	public function from($alias, $table = null) {
126
-		if($table === null) {
126
+		if ($table === null) {
127 127
 			[$alias, $table] = [$table, $alias];
128 128
 			$this->addTable($alias, (string) $table);
129 129
 		} else {
Please login to merge, or discard this patch.
src/Tools/JsonTable.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,8 +40,8 @@
 block discarded – undo
40 40
 	 */
41 41
 	private function translateColumns(Database $db, $columns) {
42 42
 		$result = [];
43
-		foreach($columns as $column) {
44
-			if(!is_string($column)) {
43
+		foreach ($columns as $column) {
44
+			if (!is_string($column)) {
45 45
 				$column = sprintf('%s %s PATH \'%s\'', $column['name'], $column['type'], $column['jsonPath']);
46 46
 			}
47 47
 			$result[] = $column;
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprFilter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
 	public function __construct(
27 27
 		private string $expression,
28 28
 		array $data,
29
-		string|array $keyPath,
29
+		string | array $keyPath,
30 30
 		$validator = null,
31 31
 		$validationResultHandler = null
32 32
 	) {
33 33
 		$this->keyPath = $this->buildKey($keyPath);
34 34
 		$this->value = RecursiveStructureAccess::recursiveGet($data, $this->keyPath, null);
35 35
 		$this->hasValue = is_scalar($this->value) ? trim((string) $this->value) !== '' : !empty($this->value);
36
-		if($validator === null) {
36
+		if ($validator === null) {
37 37
 			$validator = static fn() => true;
38 38
 		}
39 39
 		$this->validator = $validator;
40
-		if($validationResultHandler === null) {
41
-			$validationResultHandler = static function () {};
40
+		if ($validationResultHandler === null) {
41
+			$validationResultHandler = static function() {};
42 42
 		}
43 43
 		$this->validationResultHandler = $validationResultHandler;
44 44
 	}
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 	 * @return bool
55 55
 	 */
56 56
 	public function isValid(): bool {
57
-		if(!$this->hasValue) {
57
+		if (!$this->hasValue) {
58 58
 			return false;
59 59
 		}
60
-		if($this->validator !== null) {
60
+		if ($this->validator !== null) {
61 61
 			$result = call_user_func($this->validator, $this->value);
62 62
 			call_user_func($this->validationResultHandler, $result, [
63 63
 				'value' => $this->value,
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 * @return string[]
81 81
 	 */
82 82
 	private function buildKey($keyPath): array {
83
-		if(is_string($keyPath)) {
83
+		if (is_string($keyPath)) {
84 84
 			$keyPath = explode('.', $keyPath);
85 85
 		}
86
-		if(!is_array($keyPath)) {
86
+		if (!is_array($keyPath)) {
87 87
 			throw new RuntimeException('Invalid key');
88 88
 		}
89 89
 		return $keyPath;
Please login to merge, or discard this patch.