Code Duplication    Length = 24-25 lines in 2 locations

src/DataSource/ArrayDataSource.php 2 locations

@@ 221-244 (lines=24) @@
218
		$values = $condition[$filter->getColumn()];
219
		$row_value = $row[$filter->getColumn()];
220
221
		if ($values['from'] !== NULL && $values['from'] !== '') {
222
			$date_from = \DateTime::createFromFormat($format, $values['from']);
223
			if (!($date_from instanceof \DateTime)) {
224
				/** Date given is not in valid format */
225
				return FALSE;
226
			}
227
			if (!($row_value instanceof \DateTime)) {
228
				/**
229
				 * Try to convert string to DateTime object
230
				 */
231
				try {
232
					$row_value = DateTimeHelper::tryConvertToDate($row_value);
233
				} catch (DataGridDateTimeHelperException $e) {
234
					/**
235
					 * Otherwise just return raw string
236
					 */
237
					return FALSE;
238
				}
239
			}
240
241
			if ($row_value->getTimeStamp() < $date_from->getTimeStamp()) {
242
				return FALSE;
243
			}
244
		}
245
246
		if ($values['to'] !== NULL && $values['to'] !== '') {
247
			$date_to = \DateTime::createFromFormat($format, $values['to']);
@@ 246-270 (lines=25) @@
243
			}
244
		}
245
246
		if ($values['to'] !== NULL && $values['to'] !== '') {
247
			$date_to = \DateTime::createFromFormat($format, $values['to']);
248
			if (!($date_to instanceof \DateTime)) {
249
				/** Date given is not in valid format */
250
				return FALSE;
251
			}
252
253
			if (!($row_value instanceof \DateTime)) {
254
				/**
255
				 * Try to convert string to DateTime object
256
				 */
257
				try {
258
					$row_value = DateTimeHelper::tryConvertToDate($row_value);
259
				} catch (DataGridDateTimeHelperException $e) {
260
					/**
261
					 * Otherwise just return raw string
262
					 */
263
					return FALSE;
264
				}
265
			}
266
267
			if ($row_value->getTimeStamp() > $date_to->getTimeStamp()) {
268
				return FALSE;
269
			}
270
		}
271
272
		return TRUE;
273
	}