コード例 #1
0
ファイル: ValidationVisitorTest.php プロジェクト: seytar/psx
 public function testVisitDateTimeDateTime()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getDateTime('test');
     $this->assertTrue($visitor->visitDateTime(new \DateTime(), $property, ''));
 }
コード例 #2
0
ファイル: AssimilationVisitor.php プロジェクト: seytar/psx
 public function visitDateTime($data, Property\DateTimeType $property, $path)
 {
     if ($this->validate) {
         parent::visitDateTime($data, $property, $path);
     } else {
         $this->assertRequired($data, $property, $path);
     }
     if ($data instanceof \DateTime) {
         return $this->createSimpleProperty($data, $property);
     }
     try {
         return $this->createSimpleProperty(new DateTime($data), $property);
     } catch (\Exception $e) {
         throw new ValidationException($path . ' must be an valid date-time format (full-date "T" full-time) [RFC3339]');
     }
 }