<commit_before><?php

namespace App\Console\Commands;

use Bogardo\Mailgun\Facades\Mailgun;
use TCG\Voyager\Models\Setting;
use Illuminate\Console\Command;

class MailgunMessages extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'mailgun:send {args*}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send a test email via Mailgun';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $args = $this->arguments()['args'];

        if (!$args) {
            $this->error('No arguments passed');

            return;
        }

        if (!$args[0]) {
            $this->error('No message to send');

            return;
        }

        if (!$args[1]) {
            $this->error('No email address');

            return;
        }

        if (!filter_var($args[1], FILTER_VALIDATE_EMAIL)) {
            $this->error('Invalid email address');

            return;
        }

        $this->sendEmail($args[0], $args[1]);
    }

    private function sendEmail(string $text, String $email) {
        $result = Mailgun::raw($text, function ($message) use($email) {
            $message->to($email, env('MAILGUN_SENDER', ''))->subject('Mailgun Test');

            return;
        });

        if ($result->status == 200) {
            $this->info('Message sent successfully');
        }
        else {
            $this->error('Error sending email: ' . $result->message);
        }

        return;
    }
}<commit_msg>Refactored email command<commit_after><?php

namespace App\Console\Commands;

use Bogardo\Mailgun\Facades\Mailgun;
use TCG\Voyager\Models\Setting;
use Illuminate\Console\Command;

class MailgunMessages extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'mailgun:send
        {message : The email body}
        {email : Where to send the message}
        {--subject=Mailgun Test : Email subject}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send a test email via Mailgun';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $message = $this->argument('message');
        $email = $this->argument('email');
        $subject = $this->option('subject');

        if (!$message && !$email) {
            $this->error('No arguments passed');

            return;
        }

        if (!$message) {
            $this->error('No message to send');

            return;
        }

        if (!$email) {
            $this->error('No email address');

            return;
        }

        if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $this->error('Invalid email address');

            return;
        }

        $this->sendEmail($message, $email, $subject);
    }

    private function sendEmail(string $text, String $email, String $subject) {
        $result = Mailgun::raw($text, function ($message) use($email, $subject) {
            $message->to($email, env('MAILGUN_SENDER', ''))->subject($subject);

            return;
        });

        if ($result->status == 200) {
            $this->info('Message sent successfully');
        }
        else {
            $this->error('Error sending email: ' . $result->message);
        }

        return;
    }
}
{'fraction_non_alphanumeric': 0.1437024513947591, 'fraction_numerical': 0.0030994646379261764, 'mean_word_length': 1.8814935064935066, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '969402', 'n_tokens_mistral': 1020, 'n_tokens_neox': 996, 'n_words': 239}