protected function getRuleMsg($attribute, $title, $type, $rule)
{
if (isset($this->message[$attribute . '.' . $type])) {
$msg = $this->message[$attribute . '.' . $type];
} elseif (isset($this->message[$attribute])) {
$msg = $this->message[$attribute];
} elseif (isset(self::$typeMsg[$type])) {
$msg = self::$typeMsg[$type];
} else {
$msg = $title . '规则错误';
}
if (is_string($msg) && strpos($msg, '{%')) {
$msg = Lang::get(substr($msg, 2, -1));
}
if (is_string($msg) && false !== strpos($msg, ':')) {
// 变量替换
if (strpos($rule, ',')) {
$array = array_pad(explode(',', $rule), 3, '');
} else {
$array = array_pad([], 3, '');
}
$msg = str_replace([':attribute', ':rule', ':1', ':2', ':3'], [$title, (string) $rule, $array[0], $array[1], $array[2]], $msg);
}
return $msg;
}