Completed
Push — master ( 84ca8a...f50805 )
by Ron
03:04
created
src/Builder/Helpers/YieldPolyfillIterator.php 1 patch
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 use Closure;
5 5
 use Iterator;
6 6
 use Kir\MySQL\Builder\QueryStatement;
7
-use Kir\MySQL\Builder\RunnableSelect;
8 7
 use PDO;
9 8
 
10 9
 class YieldPolyfillIterator implements Iterator {
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.