Skip to content

Commit

Permalink
support DateTimeInterface instances for times
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Dec 30, 2016
1 parent 61a67ec commit 1fa9276
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -47,7 +47,7 @@ public function validate($value, Constraint $constraint)
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Time');
}

if (null === $value || '' === $value || $value instanceof \DateTime) {
if (null === $value || '' === $value || $value instanceof \DateTimeInterface) {
return;
}

Expand Down
Expand Up @@ -99,4 +99,11 @@ public function getInvalidTimes()
array('00:00:60', Time::INVALID_TIME_ERROR),
);
}

public function testDateTimeImmutableIsValid()
{
$this->validator->validate(new \DateTimeImmutable(), new Time());

$this->assertNoViolation();
}
}

0 comments on commit 1fa9276

Please sign in to comment.