定制 itselijahwood/profanity 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

itselijahwood/profanity

最新稳定版本:v1.0.2

Composer 安装命令:

composer require itselijahwood/profanity

包简介

A profanity checker, filters swear words in a string.

README 文档

README

Profanity filter is a swear word filter built in PHP. It blocks over 200+ swear words + racial slurs. Supports English, Spanish and French. I'm accepting PR's but mostly won't be available to accept / review.

Install

  composer require itselijahwood/profanity

Getting started

Get an array of swear words that are blocked

  <?php
  require 'vendor/autoload.php';

  use ItsElijahWood\Profanity\Profanity;

  $profanity = new Profanity();
  $getList = $profanity->getProfanityList();

  echo $getList;

Checks a string and returns true if it contains a swear word from the list, otherwise returns false.

  $string = "fuck you";
  $profanity = new Profanity();
  $result = $profanity->filterString($string);

  if ($result) {
    echo "Swear word found."; // Output
  } else {
    echo "No swear word.";
  }

Filters a string by replacing swear words with **** instead of returning a boolean.

  $string = "i aint testin shit";
  $profanity = new Profanity();
  $result = $profanity->censorString($string);

  echo $result; // output: "i aint testin ****"

Similar to censorString but you can choose the censorString

  $string = "sexy string";
  $replaceCensorString = "quack";

  $profanity = new Profanity();
  $getList = $profanity->replaceString($string, $replaceCensorString);

  echo $getList; // Output: quack string

Add your own custom swear word array, merges onto default array. Works for all functions

  $string = "i aint testing shit";
  $customSwearWordArray = ["testing"];

  $profanity = new Profanity();
  $getString = $profanity->censorString($string, $customSwearWordArray);

  echo $getString; // Ouput: i aint ******* ****

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-20