protected function _filterText($text)
    {
        // return true means `yes, it's banned`
        if (is_callable($this->config('bannedWords'))) {
            $isBanned = function ($word) {
                $callable = $this->config('bannedWords');

                return $callable($word);
            };
        } else {
            $isBanned = function ($word) {
                return in_array($word, (array)$this->config('bannedWords')) || empty($word);
            };
        }

        $words = explode(' ', $text);
        foreach ($words as $i => $w) {
            if ($isBanned($w)) {
                unset($words[$i]);
            }
        }

        return implode(' ', $words);
    }
protected function _filterText($text)
    {
        // return true means `yes, it's banned`
        if (is_callable($this->config('bannedWords'))) {
            $isBanned = function ($word) {
                $callable = $this->config('bannedWords');

                return $callable($word);
            };
        } else {
            $isBanned = function ($word) {
                return in_array($word, (array)$this->config('bannedWords')) || empty($word);
            };
        }

        $words = explode(' ', $text);
        foreach ($words as $i => $w) {
            if ($isBanned($w)) {
                unset($words[$i]);
            }
        }

        return implode(' ', $words);
    }
protected function _filterText ( $ text ) { // return true means `yes, it's banned` if ( is_callable ( $ this -> config ( 'bannedWords' ) ) ) { $ isBanned = function ( $ word ) { $ callable = $ this -> config ( 'bannedWords' ) ; return $ callable ( $ word ) ; } ; } else { $ isBanned = function ( $ word ) { return in_array ( $ word , ( array ) $ this -> config ( 'bannedWords' ) ) || empty ( $ word ) ; } ; } $ words = explode ( ' ' , $ text ) ; foreach ( $ words as $ i => $ w ) { if ( $ isBanned ( $ w ) ) { unset ( $ words [ $ i ] ) ; } } return implode ( ' ' , $ words ) ; }
Removes any invalid word from the given text.

@param string $text The text to filter
@return string Filtered text
Removes any invalid word from the given text .