Exemplo n.º 1
0
 public function testGetInvalidDetails()
 {
     $validator = new DateTime();
     $read = $validator->getInvalidDetails();
     $expected = 'dateTime';
     $this->assertSame($read, $expected);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function isValid($value, array $parameters)
 {
     if (count($parameters) < $this->amountOfParameters) {
         throw new ValidationException('"' . $this->type . '" expects at least ' . $this->amountOfParameters . ' parameter.');
     }
     if (in_array($value, ['', null], true)) {
         return true;
     }
     $format = $this->getDateTimeFormat($parameters);
     $datetimes = $this->getDateTimes($parameters, $format);
     $date = \DateTime::createFromFormat($format, $value);
     if ($date === false) {
         return false;
     }
     return $this->isValidComparison($date, $datetimes, $parameters);
 }