Code Duplication    Length = 10-10 lines in 3 locations

src/SilverStripe/BehatExtension/Context/BasicContext.php 3 locations

@@ 514-523 (lines=10) @@
511
	 *
512
	 * @Transform /^(?:(the|a)) time of (?<val>.*)$/
513
	 */
514
	public function castRelativeToAbsoluteTime($prefix, $val) {
515
		$timestamp = strtotime($val);
516
		if(!$timestamp) {
517
			throw new \InvalidArgumentException(sprintf(
518
				"Can't resolve '%s' into a valid datetime value",
519
				$val
520
			));
521
		}
522
		return date($this->timeFormat, $timestamp);
523
	}
524
525
	/**
526
	 * Transforms relative date and time statements compatible with strtotime().
@@ 532-541 (lines=10) @@
529
	 *
530
	 * @Transform /^(?:(the|a)) datetime of (?<val>.*)$/
531
	 */
532
	public function castRelativeToAbsoluteDatetime($prefix, $val) {
533
		$timestamp = strtotime($val);
534
		if(!$timestamp) {
535
			throw new \InvalidArgumentException(sprintf(
536
				"Can't resolve '%s' into a valid datetime value",
537
				$val
538
			));
539
		}
540
		return date($this->datetimeFormat, $timestamp);
541
	}
542
543
	/**
544
	 * Transforms relative date statements compatible with strtotime().
@@ 550-559 (lines=10) @@
547
	 *
548
	 * @Transform /^(?:(the|a)) date of (?<val>.*)$/
549
	 */
550
	public function castRelativeToAbsoluteDate($prefix, $val) {
551
		$timestamp = strtotime($val);
552
		if(!$timestamp) {
553
			throw new \InvalidArgumentException(sprintf(
554
				"Can't resolve '%s' into a valid datetime value",
555
				$val
556
			));
557
		}
558
		return date($this->dateFormat, $timestamp);
559
	}
560
561
	public function getDateFormat() {
562
		return $this->dateFormat;