diff --git a/README.md b/README.md index 858cfb6..7ef7200 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ return [ 'config' => [ 'repeat' => true, // 重复替换为敏感词相同长度的字符 - 'replaceChar' => '*', // 替换字符 + 'replace_char' => '*', // 替换字符 // 标记敏感词,标签生成敏感词 'mark' => 'mark', ], @@ -101,7 +101,7 @@ class Index } ``` -依赖注入方式,推荐 +依赖注入方式 ```php use isszz\sensitive\Sensitive; diff --git a/src/Sensitive.php b/src/Sensitive.php index 274498b..46f8d83 100644 --- a/src/Sensitive.php +++ b/src/Sensitive.php @@ -161,9 +161,7 @@ public function replace(string $content, string $replaceChar = '', bool $repeat throw new SensitiveException('Please fill in the content of the test', 1); } - if(!$replaceChar) { - $replaceChar = $this->config['replaceChar'] ?? ''; - } + $replaceChar = $replaceChar ?: $this->config['replace_char']; if(!$repeat) { $repeat = $this->config['repeat'] ?? false; diff --git a/src/config/plugin/isszz/webman-sensitive/app.php b/src/config/plugin/isszz/webman-sensitive/app.php index 231685a..dab0d6a 100644 --- a/src/config/plugin/isszz/webman-sensitive/app.php +++ b/src/config/plugin/isszz/webman-sensitive/app.php @@ -8,7 +8,7 @@ 'mode' => 'file', 'config' => [ 'repeat' => true, // 重复替换为敏感词相同长度的字符 - 'replaceChar' => '*', // 替换字符 + 'replace_char' => '*', // 替换字符 // 标记敏感词,标签生成敏感词 'mark' => 'mark', ],