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