lswl/sensitive

Filter sensitive words based on determination of Finite Automata (DFA) algorithm.

v1.0.0 2021-10-13 03:59 UTC

This package is auto-updated.

Last update: 2024-04-13 11:02:32 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('这是需要验证的字符串', '错误消息前缀');