public function visitDuration($data, Property\DurationType $property, $path) { $this->assertRequired($data, $property, $path); if ($data === null) { return true; } elseif ($data instanceof \DateInterval) { return true; } elseif (is_string($data)) { $result = preg_match('/^' . DateTime\Duration::getPattern() . '$/', $data); if ($result) { return true; } } throw new ValidationException($path . ' must be an valid duration format [ISO8601]'); }