public function add($selector, $name = null, $options = null, $messageTemplate = null, $label = null)
{
// the $selector is an associative array with $selector => $rules
if (func_num_args() == 1) {
if (!is_array($selector)) {
throw new \InvalidArgumentException('If $selector is the only argument it must be an array');
}
return $this->addMultiple($selector);
}
// check if the selector is in the form of 'selector:Label'
if (strpos($selector, ':') !== false) {
list($selector, $label) = explode(':', $selector, 2);
}
$this->ensureSelectorRulesExist($selector, $label);
call_user_func(array($this->rules[$selector], 'add'), $name, $options, $messageTemplate, $label);
return $this;
}