Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blasp::check() matched profanity stays persistent #15

Open
swen4 opened this issue Jan 20, 2025 · 0 comments
Open

Blasp::check() matched profanity stays persistent #15

swen4 opened this issue Jan 20, 2025 · 0 comments

Comments

@swen4
Copy link

swen4 commented Jan 20, 2025

I wrote an Artisan command that checks a large list of models for profanity. The general gist is:

public function checkUserNamesForProfanity()
{
    $users = User::all();

    foreach ($users as $user) {
        $name = $user->name;

        if (!empty($name)) {
            echo "Checking name of user ID: " . $user->id . PHP_EOL;

            $blasp = Blasp::check($name);

            if ($blasp->hasProfanity()) {
                $profanities = implode(', ', $blasp->getUniqueProfanitiesFound());
                echo "Profanity found in user ID: " . $user->id . PHP_EOL;
                echo "Name: " . $name . PHP_EOL;
                echo "Profanity matched: " . $profanities . PHP_EOL;
            }
        }
    }
}

The output of "Profanity matched:" will continue the grow as long as the command is running, adding onto profanity found in previous matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant