class Helper

Properties

string $allowed
string $attrName
string $defaultReplacement
string $regexp
string $regexpHtml
array $replacements
string $tagName

Methods

__construct(array $config)

Constructor

string
censorHtml(string $html, bool $censorAttributes = false)

Censor text nodes inside of HTML code

string
censorText(string $text)

Censor given plain text

bool
isCensored(string $word)

Test whether given word is censored

string
getReplacement(string $word)

Get the replacement for given word

bool
isAllowed(string $word)

Test whether given word is allowed (whitelisted)

Details

at line 52
__construct(array $config)

Constructor

Parameters

array $config

Helper's config

at line 69
string censorHtml(string $html, bool $censorAttributes = false)

Censor text nodes inside of HTML code

NOTE: will only recognize attributes that are enclosed in double quotes

Parameters

string $html

Original HTML

bool $censorAttributes

Whether to censor the content of attributes

Return Value

string

Censored HTML

at line 103
string censorText(string $text)

Censor given plain text

Parameters

string $text

Original text

Return Value

string

Censored text

at line 121
bool isCensored(string $word)

Test whether given word is censored

Parameters

string $word

Return Value

bool

at line 132
protected string getReplacement(string $word)

Get the replacement for given word

Parameters

string $word

Original word

Return Value

string

Replacement if the word is censored, or the original word otherwise

at line 156
protected bool isAllowed(string $word)

Test whether given word is allowed (whitelisted)

Parameters

string $word

Return Value

bool