Skip to content

chaucerbao/censorship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Censorship

Censorship is a PHP library that covers up undesired words

Getting Started

First, you'll need to load an array of censored words.

$censorship = new Chaucerbao\Censorship;
$censorship->load(['happy', 'flower']);
$censorship->censor('I am so happy when I get flowers for my birthday!');

// I am so ***** when I get ******* for my birthday!

You can also load words from the constructor

$censorship = new Chaucerbao\Censorship(['happy', 'flower']);

If you prefer to cover the letters with a different symbol, you can use either:

$censorship->setSymbol('-'); // Changes the default symbol for future calls
$censorship->censor('Your sentence.', '-'); // Uses the symbol for this instance only

Public methods

Load undesired words

void load(array $words)

Set the symbol

You can change the default symbol (*) used to cover up the letters.

void setSymbol(string $symbol)

Censor the text

Returns the text with the undesired words covered. Passing in a $symbol will override the default symbol for this call.

string censor(string $text[, string $symbol])

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages