Passed
Push — master ( de7ea0...47a5c3 )
by Ron
01:40
created
src/Builder/Expr/DBExprFilter.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 		$this->value = $data;
28 28
 		$this->keyPath = $this->buildKey($keyPath);
29 29
 		$this->value = $this->recursiveGet($data, $this->keyPath, null);
30
-		if($validator === null) {
31
-			$validator = function ($data) {
32
-				if(is_array($data)) {
30
+		if ($validator === null) {
31
+			$validator = function($data) {
32
+				if (is_array($data)) {
33 33
 					return $this->isValidArray($data);
34 34
 				}
35 35
 				return (string) $data !== '';
36 36
 			};
37 37
 		}
38
-		if($validationResultHandler === null) {
39
-			$validationResultHandler = static function () {};
38
+		if ($validationResultHandler === null) {
39
+			$validationResultHandler = static function() {};
40 40
 		}
41 41
 		$this->validator = $validator;
42 42
 		$this->validationResultHandler = $validationResultHandler;
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @return string[]
74 74
 	 */
75 75
 	private function buildKey($keyPath): array {
76
-		if(is_string($keyPath)) {
76
+		if (is_string($keyPath)) {
77 77
 			$keyPath = explode('.', $keyPath);
78 78
 		}
79
-		if(!is_array($keyPath)) {
79
+		if (!is_array($keyPath)) {
80 80
 			throw new RuntimeException('Invalid key');
81 81
 		}
82 82
 		return $keyPath;
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @return bool
88 88
 	 */
89 89
 	private function isValidArray(array $array): bool {
90
-		$data = array_filter($array, function ($value) {
91
-			if(is_array($value)) {
90
+		$data = array_filter($array, function($value) {
91
+			if (is_array($value)) {
92 92
 				return $this->isValidArray($value);
93 93
 			}
94 94
 			return (string) $value !== '';
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 		if (!$count) {
108 108
 			return $default;
109 109
 		}
110
-		foreach($path as $idxValue) {
110
+		foreach ($path as $idxValue) {
111 111
 			$part = $idxValue;
112
-			if(!array_key_exists($part, $array)) {
112
+			if (!array_key_exists($part, $array)) {
113 113
 				return $default;
114 114
 			}
115 115
 			$array = $array[$part];
Please login to merge, or discard this patch.
src/Builder/Expr/RequiredDBFilterMap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 	 * @return DBExprFilter
35 35
 	 */
36 36
 	public function __invoke(string $expression, $keyPath, $validator = null) {
37
-		return new DBExprFilter($expression, $this->map, $keyPath, $validator, static function ($result, array $data) {
38
-			if(!$result) {
37
+		return new DBExprFilter($expression, $this->map, $keyPath, $validator, static function($result, array $data) {
38
+			if (!$result) {
39 39
 				throw new RequiredValueNotFoundException(sprintf("Required value %s not found", $data['key']));
40 40
 			}
41 41
 		});
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprOrderBySpec.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
 	 */
12 12
 	public function __construct(array $spec, array $sortFieldsSpec) {
13 13
 		$expressions = [];
14
-		foreach($spec as $specReference => $dbExpr) {
15
-			if(is_int($specReference)) {
14
+		foreach ($spec as $specReference => $dbExpr) {
15
+			if (is_int($specReference)) {
16 16
 				$specReference = $dbExpr;
17 17
 			}
18 18
 			$expressions[$specReference] = $dbExpr;
19 19
 		}
20
-		foreach($sortFieldsSpec as $sortFieldSpec) {
21
-			if(array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) {
20
+		foreach ($sortFieldsSpec as $sortFieldSpec) {
21
+			if (array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) {
22 22
 				$direction = 'ASC';
23
-				if(array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') {
23
+				if (array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') {
24 24
 					$direction = 'DESC';
25 25
 				}
26 26
 				$this->fields[] = [
Please login to merge, or discard this patch.
src/Builder/Helpers/LazyRowGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@
 block discarded – undo
22 22
 	 * @return Generator|mixed[]
23 23
 	 */
24 24
 	public function generate(QueryStatement $statement, Closure $callback = null) {
25
-		while($row = $statement->fetch()) {
26
-			if($this->preserveTypes) {
25
+		while ($row = $statement->fetch()) {
26
+			if ($this->preserveTypes) {
27 27
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
28 28
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
29 29
 			}
30
-			if($callback !== null) {
30
+			if ($callback !== null) {
31 31
 				$result = $callback($row);
32
-				if($result instanceof DBIgnoreRow) {
32
+				if ($result instanceof DBIgnoreRow) {
33 33
 					// Do nothing in this case
34 34
 					continue;
35
-				} elseif($result !== null) {
35
+				} elseif ($result !== null) {
36 36
 					yield $result;
37 37
 				} else {
38 38
 					yield $row;
Please login to merge, or discard this patch.
src/Builder/Helpers/FieldTypeProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	 */
11 11
 	public static function getFieldTypes(QueryStatement $statement): array {
12 12
 		$fieldTypes = [];
13
-		for($i = 0; $column = $statement->getColumnMeta($i); $i++) {
13
+		for ($i = 0; $column = $statement->getColumnMeta($i); $i++) {
14 14
 			$fieldTypes[$column['name']] = self::getTypeFromNativeType($column['native_type']);
15 15
 		}
16 16
 		return $fieldTypes;
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): 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/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.