Completed
Push — master ( f50805...de8a99 )
by Ron
05:45
created
src/Builder/Helpers/LazyRowGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@
 block discarded – undo
21 21
 	 * @return array[]|\Generator
22 22
 	 */
23 23
 	public function generate(QueryStatement $statement, Closure $callback = null) {
24
-		while($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
25
-			if($this->preserveTypes) {
24
+		while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) {
25
+			if ($this->preserveTypes) {
26 26
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
27 27
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
28 28
 			}
29
-			if($callback !== null) {
29
+			if ($callback !== null) {
30 30
 				$result = $callback($row);
31
-				if($result instanceof DBIgnoreRow) {
31
+				if ($result instanceof DBIgnoreRow) {
32 32
 					// Do nothing in this case
33
-				} elseif($result !== null) {
33
+				} elseif ($result !== null) {
34 34
 					yield $result;
35 35
 				} else {
36 36
 					yield $row;
Please login to merge, or discard this patch.
src/Builder/Helpers/YieldPolyfillIterator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function current() {
49 49
 		$row = $this->currentItem;
50
-		if($this->preserveTypes) {
50
+		if ($this->preserveTypes) {
51 51
 			$columnDefinitions = FieldTypeProvider::getFieldTypes($this->getStmt());
52 52
 			$row = FieldValueConverter::convertValues($row, $columnDefinitions);
53 53
 		}
54 54
 		$callback = $this->callback;
55
-		if($callback !== null) {
55
+		if ($callback !== null) {
56 56
 			$result = $callback($row);
57
-			if($result instanceof DBIgnoreRow) {
57
+			if ($result instanceof DBIgnoreRow) {
58 58
 				// Do nothing in this case
59
-			} elseif($result !== null) {
59
+			} elseif ($result !== null) {
60 60
 				return $result;
61 61
 			} else {
62 62
 				return $row;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	public function valid() {
87 87
 		$result = !!$this->currentItem;
88
-		if(!$result) {
88
+		if (!$result) {
89 89
 			$this->closeCursor();
90 90
 		}
91 91
 		return $result;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	 */
96 96
 	public function rewind() {
97
-		if($this->stmt !== null) {
97
+		if ($this->stmt !== null) {
98 98
 			throw new \Exception("It's not possible to rewind this iterator");
99 99
 		}
100 100
 		$this->stmt = call_user_func($this->statementFactory);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return QueryStatement
107 107
 	 */
108 108
 	private function getStmt() {
109
-		if($this->stmt === null) {
109
+		if ($this->stmt === null) {
110 110
 			$this->rewind();
111 111
 		}
112 112
 		return $this->stmt;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	/**
116 116
 	 */
117 117
 	private function closeCursor() {
118
-		if($this->stmt instanceof QueryStatement) {
118
+		if ($this->stmt instanceof QueryStatement) {
119 119
 			$this->stmt->closeCursor();
120 120
 		}
121 121
 		$this->stmt = null;
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($query, $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/RunnableSelect.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
 	 * @return array[]
62 62
 	 */
63 63
 	public function fetchRows(Closure $callback = null) {
64
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback) {
64
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback) {
65 65
 			$data = $statement->fetchAll(\PDO::FETCH_ASSOC);
66
-			if($this->preserveTypes) {
66
+			if ($this->preserveTypes) {
67 67
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
68
-				foreach($data as &$row) {
68
+				foreach ($data as &$row) {
69 69
 					$row = FieldValueConverter::convertValues($row, $columnDefinitions);
70 70
 				}
71 71
 			}
72
-			if($callback !== null) {
73
-				return call_user_func(function ($resultData = []) use ($data, $callback) {
74
-					foreach($data as $row) {
72
+			if ($callback !== null) {
73
+				return call_user_func(function($resultData = []) use ($data, $callback) {
74
+					foreach ($data as $row) {
75 75
 						$result = $callback($row);
76
-						if($result !== null && !($result instanceof DBIgnoreRow)) {
76
+						if ($result !== null && !($result instanceof DBIgnoreRow)) {
77 77
 							$resultData[] = $result;
78 78
 						} else {
79 79
 							$resultData[] = $row;
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @return array[]|\Generator
92 92
 	 */
93 93
 	public function fetchRowsLazy(Closure $callback = null) {
94
-		if(version_compare(PHP_VERSION, '5.5', '<')) {
95
-			return new YieldPolyfillIterator($callback, $this->preserveTypes, function () {
94
+		if (version_compare(PHP_VERSION, '5.5', '<')) {
95
+			return new YieldPolyfillIterator($callback, $this->preserveTypes, function() {
96 96
 				return $this->createStatement();
97 97
 			});
98 98
 		}
@@ -107,18 +107,18 @@  discard block
 block discarded – undo
107 107
 	 * @throws \Exception
108 108
 	 */
109 109
 	public function fetchRow(Closure $callback = null) {
110
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback) {
110
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback) {
111 111
 			$row = $statement->fetch(\PDO::FETCH_ASSOC);
112
-			if(!is_array($row)) {
112
+			if (!is_array($row)) {
113 113
 				return [];
114 114
 			}
115
-			if($this->preserveTypes) {
115
+			if ($this->preserveTypes) {
116 116
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
117 117
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
118 118
 			}
119
-			if($callback !== null) {
119
+			if ($callback !== null) {
120 120
 				$result = $callback($row);
121
-				if($result !== null) {
121
+				if ($result !== null) {
122 122
 					$row = $result;
123 123
 				}
124 124
 			}
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 	 * @return mixed[]
132 132
 	 */
133 133
 	public function fetchKeyValue($treatValueAsArray = false) {
134
-		return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) {
135
-			if($treatValueAsArray) {
134
+		return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) {
135
+			if ($treatValueAsArray) {
136 136
 				$rows = $statement->fetchAll(\PDO::FETCH_ASSOC);
137 137
 				$result = array();
138
-				foreach($rows as $row) {
138
+				foreach ($rows as $row) {
139 139
 					list($key) = array_values($row);
140 140
 					$result[$key] = $row;
141 141
 				}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	public function fetchGroups(array $fields) {
153 153
 		$rows = $this->fetchRows();
154 154
 		$result = array();
155
-		foreach($rows as $row) {
155
+		foreach ($rows as $row) {
156 156
 			$tmp = &$result;
157
-			foreach($fields as $field) {
157
+			foreach ($fields as $field) {
158 158
 				$value = $row[$field];
159
-				if(!array_key_exists($value, $tmp)) {
159
+				if (!array_key_exists($value, $tmp)) {
160 160
 					$tmp[$value] = [];
161 161
 				}
162 162
 				$tmp = &$tmp[$value];
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @return string[]
171 171
 	 */
172 172
 	public function fetchArray() {
173
-		return $this->createTempStatement(function (QueryStatement $stmt) {
173
+		return $this->createTempStatement(function(QueryStatement $stmt) {
174 174
 			return $stmt->fetchAll(\PDO::FETCH_COLUMN);
175 175
 		});
176 176
 	}
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	 * @return null|bool|string|int|float
181 181
 	 */
182 182
 	public function fetchValue($default = null) {
183
-		return $this->createTempStatement(function (QueryStatement $stmt) use ($default) {
183
+		return $this->createTempStatement(function(QueryStatement $stmt) use ($default) {
184 184
 			$result = $stmt->fetch(\PDO::FETCH_NUM);
185
-			if($result !== false) {
185
+			if ($result !== false) {
186 186
 				return $result[0];
187 187
 			}
188 188
 			return $default;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$query = $this->__toString();
223 223
 		$statement = $db->prepare($query);
224 224
 		$statement->execute($this->values);
225
-		if($this->getCalcFoundRows()) {
225
+		if ($this->getCalcFoundRows()) {
226 226
 			$this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn();
227 227
 		}
228 228
 		return $statement;
Please login to merge, or discard this patch.