jmhc / sensitive
Filter sensitive words based on determination of Finite Automata (DFA) algorithm.
v1.0.0
2020-11-18 06:46 UTC
Requires
- php: ^7.2
- lustre/php-dfa-sensitive: ^1.0
This package is auto-updated.
Last update: 2025-02-18 16:02:11 UTC
README
基于 lustre/php-dfa-sensitive 添加了默认敏感词库
安装
composer require jmhc/sensitive
使用
use Jmhc\Sensitive\SensitiveService; // 实例化服务 $sensitive = new SensitiveService(); // 设置敏感字符串数组 $sensitive->setSensitiveWords([]); // 设置排除字符串数组 $sensitive->setExceptWords([]); // 使用敏感词库,默认使用 $sensitive->withSensitiveWordLibrary(true); // 验证,有敏感词会抛出 Jmhc\Sensitive\SensitiveException 异常 $sensitive->validate('这是需要验证的字符串', '错误消息前缀');