Code Duplication    Length = 17-19 lines in 2 locations

src/DataSource/DoctrineDataSource.php 1 location

@@ 267-283 (lines=17) @@
264
	 * @param  array  $sorting
265
	 * @return static
266
	 */
267
	public function sort(array $sorting)
268
	{
269
		if (!empty($sorting)) {
270
			foreach ($sorting as $column => $sort) {
271
				$this->data_source->addOrderBy($this->checkAliases($column), $sort);
272
			}
273
		} else {
274
			/**
275
			 * Has the statement already a order by clause?
276
			 */
277
			if (!$this->data_source->getDQLPart('orderBy')) {
278
				$this->data_source->orderBy($this->checkAliases($this->primary_key));
279
			}
280
		}
281
282
		return $this;
283
	}
284
285
286
	/**

src/DataSource/NetteDatabaseTableDataSource.php 1 location

@@ 228-246 (lines=19) @@
225
	 * @param  array  $sorting
226
	 * @return static
227
	 */
228
	public function sort(array $sorting)
229
	{
230
		if (!empty($sorting)) {
231
			$this->data_source->getSqlBuilder()->setOrder([], []);
232
233
			foreach ($sorting as $column => $sort) {
234
				$this->data_source->order("$column $sort");
235
			}
236
		} else {
237
			/**
238
			 * Has the statement already a order by clause?
239
			 */
240
			if (!$this->data_source->getSqlBuilder()->getOrder()) {
241
				$this->data_source->order($this->primary_key);
242
			}
243
		}
244
245
		return $this;
246
	}
247
248
}
249