Passed
Push — master ( 8eeffd...e04522 )
by Ron
02:19
created
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.
src/Builder/Expr/DBOrderSpec.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@
 block discarded – undo
41 41
 	public function getFields(): array {
42 42
 		$fields = [];
43 43
 		$max = $this->options['max_sort_instructions'] ?? 16;
44
-		foreach($this->sortingInstruction as $alias => $direction) {
44
+		foreach ($this->sortingInstruction as $alias => $direction) {
45 45
 			$direction = strtolower($direction) === 'desc' ? 'DESC' : 'ASC';
46
-			if(!array_key_exists($alias, $this->sortSpecification)) {
46
+			if (!array_key_exists($alias, $this->sortSpecification)) {
47 47
 				throw new DBSortAliasNotFoundException('Sorting: Alias for DB-Expression not found');
48 48
 			}
49 49
 			$fields[] = [$this->sortSpecification[$alias], $direction];
50
-			if($max < 1) {
50
+			if ($max < 1) {
51 51
 				throw new DBSortTooManyInstructionsException();
52 52
 			}
53 53
 			$max--;
Please login to merge, or discard this patch.
src/Builder/Value/DBOptionalValue.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
 	 * @return bool
28 28
 	 */
29 29
 	public function isValid(): bool {
30
-		if(!RecursiveStructureAccess::recursiveHas($this->data, $this->path)) {
30
+		if (!RecursiveStructureAccess::recursiveHas($this->data, $this->path)) {
31 31
 			return false;
32 32
 		}
33
-		if($this->validator !== null) {
33
+		if ($this->validator !== null) {
34 34
 			$value = $this->getValue();
35 35
 			return call_user_func($this->validator, $value);
36 36
 		}
Please login to merge, or discard this patch.
src/Builder/Traits/OffsetBuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @return null|int
13 13
 	 */
14 14
 	protected function getOffset(): ?int {
15
-		if($this->offset instanceof OptionalValue) {
15
+		if ($this->offset instanceof OptionalValue) {
16 16
 			return $this->offset->getValue();
17 17
 		}
18 18
 		return $this->offset;
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	protected function buildOffset(string $query): string {
35 35
 		$offset = $this->getOffset();
36
-		if($this->offset instanceof OptionalValue) {
37
-			if($this->offset->isValid()) {
36
+		if ($this->offset instanceof OptionalValue) {
37
+			if ($this->offset->isValid()) {
38 38
 				$value = $this->offset->getValue();
39
-				if(!preg_match('{\\d+}', $value)) {
39
+				if (!preg_match('{\\d+}', $value)) {
40 40
 					throw new InvalidValueException('Value for OFFSET has to be a number');
41 41
 				}
42 42
 				$query .= "OFFSET\n\t{$this->offset->getValue()}\n";
43 43
 			}
44
-		} elseif($offset !== null) {
44
+		} elseif ($offset !== null) {
45 45
 			$query .= "OFFSET\n\t{$this->offset}\n";
46 46
 		}
47 47
 		return $query;
Please login to merge, or discard this patch.
src/Builder/Traits/LimitBuilder.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @return null|int
13 13
 	 */
14 14
 	protected function getLimit(): ?int {
15
-		if($this->limit instanceof OptionalValue) {
15
+		if ($this->limit instanceof OptionalValue) {
16 16
 			return $this->limit->getValue();
17 17
 		}
18 18
 		return $this->limit;
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	protected function buildLimit(string $query, ?int $offset = null) {
36 36
 		$limit = $this->getLimit();
37
-		if($limit === null && $offset !== null) {
37
+		if ($limit === null && $offset !== null) {
38 38
 			$limit = '18446744073709551615';
39 39
 		}
40
-		if($this->limit instanceof OptionalValue) {
41
-			if($this->limit->isValid()) {
40
+		if ($this->limit instanceof OptionalValue) {
41
+			if ($this->limit->isValid()) {
42 42
 				$value = $this->limit->getValue();
43
-				if(!preg_match('{\\d+}', $value)) {
43
+				if (!preg_match('{\\d+}', $value)) {
44 44
 					throw new InvalidValueException('Value for LIMIT has to be a number');
45 45
 				}
46 46
 				$query .= "LIMIT\n\t{$this->limit->getValue()}\n";
47 47
 			}
48
-		} elseif($limit !== null) {
48
+		} elseif ($limit !== null) {
49 49
 			$query .= "LIMIT\n\t{$limit}\n";
50 50
 		}
51 51
 		return $query;
Please login to merge, or discard this patch.
src/Databases/MySQL/MySQLExceptionInterpreter.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
 		/** @link http://php.net/manual/en/class.exception.php#Hcom115813 (cHao's comment) */
20 20
 		$code = is_array($errorInfo) && isset($errorInfo[1]) ? ((int) $errorInfo[1]) : ((int) $exception->getCode());
21 21
 		$message = $exception->getMessage();
22
-		switch($code) {
22
+		switch ($code) {
23 23
 			case 2006: return new DatabaseHasGoneAwayException($message, $code, $exception);
24 24
 			case 1213: return new SqlDeadLockException($message, $code, $exception);
25 25
 			case 1205: return new LockWaitTimeoutExceededException($message, $code, $exception);
Please login to merge, or discard this patch.