catchAdmin/extend/catcher/validates/SensitiveWord.php

31 lines
585 B
PHP
Raw Permalink Normal View History

2020-06-17 23:02:12 +08:00
<?php
2020-06-18 16:29:54 +08:00
namespace catcher\validates;
use catcher\library\Trie;
class SensitiveWord implements ValidateInterface
{
protected $word;
public function type(): string
{
// TODO: Implement type() method.
return 'sensitive_word';
}
public function verify($value): bool
{
$trie = app(Trie::class);
$word = $trie->getSensitiveWords($trie->getTries(), $value, false);
return !$word;
}
public function message(): string
{
// TODO: Implement message() method.
return '内容包含敏感词';
}
}