Skip to content

Commit 24cb6c3

Browse files
committed
feat: made $text optional when passing $exploded
1 parent c59c2b2 commit 24cb6c3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

main.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,18 @@ function getHttpAcceptLanguages(): void
9999
/**
100100
* Check if a string contains profanity, it uses methods to make sure that it is fast.
101101
*
102-
* @param string &$text The string to check.
102+
* @param string &$text The string to check. Optional. If not provided, then $exploded must be provided.
103103
* @param array $detectedLanguages = [] The languages that were detected in the string. Optional.
104-
* @param array &$exploded = [] The exploded and cleaned string to remove punctuations and emojis. Optional.
104+
* @param array &$exploded = [] The exploded and cleaned string to remove punctuations and emojis. Optional. If not provided, then $text must be provided.
105105
* @param int &explodedLength = 0 The length of the exploded string. Optional.
106106
* @param bool $all = false If true, it will check for all the languages available. Optional.
107107
* @return bool true if the string contains profanity, false if not.
108108
*/
109-
function isProfanity(&$text, $detectedLanguages = [], &$exploded = [], &$explodedLength = 0, $all = false): bool
109+
function isProfanity(&$text = "", $detectedLanguages = [], &$exploded = [], &$explodedLength = 0, $all = false): bool
110110
{
111+
if (empty($text) && empty($exploded)) {
112+
return false;
113+
}
111114
global $supportedLanguages;
112115
$badWords = array(
113116
"badWords" => array(),

0 commit comments

Comments
 (0)