コード例 #1
0
ファイル: AssimilationVisitor.php プロジェクト: seytar/psx
 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]');
     }
 }
コード例 #2
0
ファイル: ValidationVisitor.php プロジェクト: seytar/psx
 public function visitTime($data, Property\TimeType $property, $path)
 {
     $this->assertRequired($data, $property, $path);
     if ($data === null) {
         return true;
     } elseif ($data instanceof \DateTime) {
         return true;
     } elseif (is_string($data)) {
         $result = preg_match('/^' . DateTime\Time::getPattern() . '$/', $data);
         if ($result) {
             return true;
         }
     }
     throw new ValidationException($path . ' must be an valid full-time format (partial-time time-offset) [RFC3339]');
 }