PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / library / HTMLPurifier / ConfigSchema / Interchange.php
blob0e08ae8fe7aab91891dc9d3005c0013ef237c823
1 <?php
3 /**
4 * Generic schema interchange format that can be converted to a runtime
5 * representation (HTMLPurifier_ConfigSchema) or HTML documentation. Members
6 * are completely validated.
7 */
8 class HTMLPurifier_ConfigSchema_Interchange
11 /**
12 * Name of the application this schema is describing.
13 * @type string
15 public $name;
17 /**
18 * Array of Directive ID => array(directive info)
19 * @type HTMLPurifier_ConfigSchema_Interchange_Directive[]
21 public $directives = array();
23 /**
24 * Adds a directive array to $directives
25 * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive
26 * @throws HTMLPurifier_ConfigSchema_Exception
28 public function addDirective($directive)
30 if (isset($this->directives[$i = $directive->id->toString()])) {
31 throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'");
33 $this->directives[$i] = $directive;
36 /**
37 * Convenience function to perform standard validation. Throws exception
38 * on failed validation.
40 public function validate()
42 $validator = new HTMLPurifier_ConfigSchema_Validator();
43 return $validator->validate($this);
47 // vim: et sw=4 sts=4