1. UML类图
2. 方法详解
2.1 添加验证因子 addItem() 方法
- 参数:
string $name 验证名称mixed $rule 验证规则string $msg 提示信息
- 返回:
self 源码:如下 ```php protected function addItem(string $name, $rule = null, string $msg = ‘’)
{ if ($rule || 0 === $rule) {$this->rule[$name] = $rule;
} else {
$this->rule[] = $name;
}
$this->message[] = $msg;
return $this; }
<a name="fYmjk"></a>#### 2.2 获取验证规则 `getRule()` 方法- **参数:**无<br />- **返回:**`array`- **源码:**如下```phppublic function getRule(): array{return $this->rule;}
2.3 获取验证字段名称(描述) getTitle() 方法
- 参数:无
- 返回:
string 源码:如下
public function getTitle(): string{return $this->title ?: '';}
2.4 获取验证提示
getMsg()方法参数:无
- 返回:
array 源码:如下
public function getMsg(): array{return $this->message;}
2.5 设置验证字段名称
title()方法参数:
string $title验证字段名称
- 返回:
self 源码:如下
public function title(string $title){$this->title = $title;return $this;}
2.6 魔术方法
__call()源码:如下
public function __call($method, $args){if ('is' == strtolower(substr($method, 0, 2))) {$method = substr($method, 2);}array_unshift($args, lcfirst($method));return call_user_func_array([$this, 'addItem'], $args);}
2.7 魔术方法
__callStatic源码:如下:w
public static function __callStatic($method, $args){$rule = new static();if ('is' == strtolower(substr($method, 0, 2))) {$method = substr($method, 2);}array_unshift($args, lcfirst($method));return call_user_func_array([$rule, 'addItem'], $args);}
