<commit_before><?php

namespace Bluora\LaravelTwilio;

use Log;
use Twilio\Rest\Client;
use TwilioException;

class Sms
{
    /**
     * Twilio client.
     * @var Twilio\Rest\Client
     */
    private $client;

    /**
     * Create client.
     *
     * @return void
     */
    private function client()
    {
        if (is_null($this->client)) {
            $this->client = new Client(env('TWILIO_ACCOUNT_SID'), env('TWILIO_AUTH_TOKEN'));
        }
    }

    /**
     * Send an SMS.
     *
     * @param  string       $to
     * @param  string       $body
     * @param  bool|string  $from 
     * 
     * @return bool
     */
    public function send($to, $body, $from = false)
    {
        $this->client();

        $from = $from === false ? env('TWILIO_NUMBER') : $from;

        try {
            $this->client->messages->create(
                $to,
                [
                    'body' => $body,
                    'from' => $from
                ]
            );
            Log::info('Message sent to ' . $to);

            return true;
        } catch (TwilioException $e) {
            Log::error(
                'Could not send SMS notification.' .
                ' Twilio replied with: ' . $e
            );
        }

        return false;
    }
}<commit_msg>PHPMD corrections<commit_after><?php

namespace Bluora\LaravelTwilio;

use Log;
use Twilio\Rest\Client;
use TwilioException;

class Sms
{
    /**
     * Twilio client.
     * @var Twilio\Rest\Client
     */
    private $client;

    /**
     * Create client.
     *
     * @return void
     */
    private function client()
    {
        if (is_null($this->client)) {
            $this->client = new Client(env('TWILIO_ACCOUNT_SID'), env('TWILIO_AUTH_TOKEN'));
        }
    }

    /**
     * Send an SMS.
     *
     * @param  string       $to_number
     * @param  string       $body
     * @param  bool|string  $from 
     * 
     * @return bool
     *
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
     */
    public function send($to_number, $body, $from_number = false)
    {
        $this->client();

        $from_number = $from_number === false ? env('TWILIO_NUMBER') : $from_number;

        try {
            $this->client->messages->create(
                $to_number,
                [
                    'body' => $body,
                    'from' => $from_number
                ]
            );
            Log::info('Message sent to ' . $to_number);

            return true;
        } catch (TwilioException $e) {
            Log::error(
                'Could not send SMS notification.' .
                ' Twilio replied with: ' . $e
            );
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.1307237813884786, 'fraction_numerical': 0.0, 'mean_word_length': 1.3638743455497382, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3566157', 'n_tokens_mistral': 850, 'n_tokens_neox': 808, 'n_words': 170}