<commit_before><?php

/**
 * Created by PhpStorm.
 * User: Alessandro
 * Date: 01/12/2015
 * Time: 12:37
 */

namespace Padosoft\Test\traits;

use GuzzleHttp\Psr7\Response;

trait MailCatcherTools
{
    protected $mailcatcher;

    /**
     *
     */
    protected function getMailCatcher()
    {
        if(!isset($this->mailcatcher)) $this->mailcatcher = new \GuzzleHttp\Client(['base_uri' => env('MAIL_HOST','127.0.0.1').':'.env('MAIL_PORT_WEB','1080')]);
        return $this->mailcatcher;
    }

    /**
     * @return mixed
     */
    public function getAllEmails()
    {
        $emails = json_decode($this->getMailCatcher()->get('/messages')->getBody()->getContents(),true);
        if(empty($emails)) {
            $this->fail('No messages returned.');
        }

        return $emails;
    }

    /**
     * @return mixed
     */
    public function deleteAllMails()
    {
        return $this->getMailCatcher()->delete('/messages');
    }
<commit_msg>ADD a protocol test path for MAIL_HOST  and MAIL_PORT_WEB env.<commit_after><?php

/**
 * Created by PhpStorm.
 * User: Alessandro
 * Date: 01/12/2015
 * Time: 12:37
 */

namespace Padosoft\Test\traits;

use GuzzleHttp\Psr7\Response;

trait MailCatcherTools
{
    protected $mailcatcher;

    /**
     * @return \GuzzleHttp\Client
     */
    protected function getMailCatcher()
    {
        $host = env('MAIL_HOST','http://127.0.0.1');
        if(substr( $host, 0, 7 ) != 'http://'){
            $host = 'http://'.$host;
        }
        $port = env('MAIL_PORT_WEB','1080');
        if(!is_numeric($port)){
            $port = 1080;
        }
        if(!isset($this->mailcatcher)) $this->mailcatcher = new \GuzzleHttp\Client(['base_uri' => $host.':'.$port]);
        return $this->mailcatcher;
    }

    /**
     * @return mixed
     */
    public function getAllEmails()
    {
        $emails = json_decode($this->getMailCatcher()->get('/messages')->getBody()->getContents(),true);
        if(empty($emails)) {
            $this->fail('No messages returned.');
        }

        return $emails;
    }

    /**
     * @return mixed
     */
    public function deleteAllMails()
    {
        return $this->getMailCatcher()->delete('/messages');
    }

{'fraction_non_alphanumeric': 0.17477477477477477, 'fraction_numerical': 0.023423423423423424, 'mean_word_length': 2.349924585218703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2467660', 'n_tokens_mistral': 776, 'n_tokens_neox': 730, 'n_words': 121}