Exemplo n.º 1
0
 public function testVisitTimeDateTime()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getTime('test');
     $this->assertTrue($visitor->visitTime(new \DateTime(), $property, ''));
 }
Exemplo n.º 2
0
 public function visitTime($data, Property\TimeType $property, $path)
 {
     if ($this->validate) {
         parent::visitTime($data, $property, $path);
     } else {
         $this->assertRequired($data, $property, $path);
     }
     if ($data instanceof \DateTime) {
         return $this->createSimpleProperty(Time::fromDateTime($data), $property);
     }
     try {
         return $this->createSimpleProperty(new Time($data), $property);
     } catch (\Exception $e) {
         throw new ValidationException($path . ' must be an valid full-time format (partial-time time-offset) [RFC3339]');
     }
 }