Code Duplication    Length = 20-20 lines in 2 locations

src/Builder/RunnableSelect.php 2 locations

@@ 115-134 (lines=20) @@
112
	 * @return string[]
113
	 * @throws \Exception
114
	 */
115
	public function fetchRow(Closure $callback = null) {
116
		return $this->createTempStatement(function (QueryStatement $statement) use ($callback) {
117
			$statement->setFetchMode(PDO::FETCH_ASSOC);
118
			$row = $statement->fetch();
119
			if(!is_array($row)) {
120
				return [];
121
			}
122
			if($this->preserveTypes) {
123
				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
124
				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
125
			}
126
			if($callback !== null) {
127
				$result = $callback($row);
128
				if($result !== null) {
129
					$row = $result;
130
				}
131
			}
132
			return $row;
133
		});
134
	}
135
136
	/**
137
	 * @param string $className
@@ 194-213 (lines=20) @@
191
	 * @return string[]
192
	 * @throws \Exception
193
	 */
194
	public function fetchObject($className, Closure $callback = null) {
195
		return $this->createTempStatement(function (QueryStatement $statement) use ($className, $callback) {
196
			$statement->setFetchMode(PDO::FETCH_CLASS, $className);
197
			$row = $statement->fetch();
198
			if(!is_array($row)) {
199
				return [];
200
			}
201
			if($this->preserveTypes) {
202
				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
203
				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
204
			}
205
			if($callback !== null) {
206
				$result = $callback($row);
207
				if($result !== null) {
208
					$row = $result;
209
				}
210
			}
211
			return $row;
212
		});
213
	}
214
215
	/**
216
	 * @param bool $treatValueAsArray