/** * {@inheritDoc} * * @param array|Tokens $tokens The list of tokens. * * @throws InvalidArgumentException If the $tokens argument is not either * an array or instance of Tokens. */ public function __construct($tokens) { if ($tokens instanceof Tokens) { $tokens = $tokens->getArray(); } elseif (!is_array($tokens)) { throw InvalidArgumentException::create('The $tokens argument must be an array or instance of Tokens.'); } parent::__construct($tokens); }
/** * Validates the annotations XML document. * * @param DOMDocument|string $input The document to validate. * * @throws Exception * @throws InvalidArgumentException If $input is not valid. * @throws InvalidXmlException If the document is not valid. */ public static function validate($input) { if (is_string($input)) { $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; if (!@$doc->loadXML($input)) { throw InvalidXmlException::lastError(); } $input = $doc; } elseif (!$input instanceof DOMDocument) { throw InvalidArgumentException::create('The $input argument must be an instance of DOMDocument, %s given.', gettype($input)); } if (!@$input->schemaValidate(self::SCHEMA)) { throw InvalidXmlException::lastError(); } }