public function filter()
    {
        $bad_words = collect($this->badWords())->pluck('word')->toArray();

        return collect(explode(' ', $this->text))->map(function ($value) use ($bad_words) {
            if ($this->strict) {
                return (str_contains(strtolower($value), $bad_words)) ? $this->blockWord($value) : $value;
            }

            return in_array(strtolower($value), $bad_words) ? $this->blockWord($value) : $value;
        })->implode(' ');
    }
public function filter()
    {
        $bad_words = collect($this->badWords())->pluck('word')->toArray();

        return collect(explode(' ', $this->text))->map(function ($value) use ($bad_words) {
            if ($this->strict) {
                return (str_contains(strtolower($value), $bad_words)) ? $this->blockWord($value) : $value;
            }

            return in_array(strtolower($value), $bad_words) ? $this->blockWord($value) : $value;
        })->implode(' ');
    }
public function filter ( ) { $ bad_words = collect ( $ this -> badWords ( ) ) -> pluck ( 'word' ) -> toArray ( ) ; return collect ( explode ( ' ' , $ this -> text ) ) -> map ( function ( $ value ) use ( $ bad_words ) { if ( $ this -> strict ) { return ( str_contains ( strtolower ( $ value ) , $ bad_words ) ) ? $ this -> blockWord ( $ value ) : $ value ; } return in_array ( strtolower ( $ value ) , $ bad_words ) ? $ this -> blockWord ( $ value ) : $ value ; } ) -> implode ( ' ' ) ; }
Filter the string blocking the bad words with the blocker string.

@return string
Filter the string blocking the bad words with the blocker string .