* @license PHP License * @package wb * @subpackage Markup */ WBClass::load('WBMarkup_Validator'); /** * Markup Validator * * Validator base class * * @version 0.1.0 * @package wb * @subpackage Markup */ class WBMarkup_Validator extends WBStdClass { /** * Validator's config * * @var array */ protected $config = array(); /** * Last Error's error * * Zero if there is no error * @var int */ private $errorCode = 0; /** * Last error message * @var string */ private $errorMsg = ''; /** * Constructor * * Standard constructor * @param array */ public function __construct($parameters = array()) { } /** * Configure validator * * Set configuration parameter * *`@param array */ final public function configure($config) { $this->config = array_merge($this->config, $config); } /** * Validate Start Element * * Will be called for each start element. * Return true if validator feels responsible for this part. * If true, no further validators will be uses * * @param string $ns * @param string $tag * @param array $attributes * @param bool $isEmpty * @return bool */ public function validateStartElement($ns, $tag, $attributes, $isEmpty) { $this->flushError(); return false; } /** * Set Error Message * * @param int $code * @param string $msg */ final protected function setError($code, $msg) { $this->errorCode = $code; $this->errorMsg = $msg; } /** * Unset Error Code */ final public function flushError() { $this->errorCode = 0; $this->errorMsg = ''; } /** * Get Last Error Code * * @return int */ final public function getErrorCode() { return $this->errorCode; } /** * Get Last Error * * @return string */ final public function getErrorMsg() { return $this->errorMsg; } }