<commit_before><?php
/**
 * @link https://github.com/Izumi-kun/yii2-spoolmailer
 * @copyright Copyright (c) 2017 <NAME>
 * @license http://opensource.org/licenses/BSD-3-Clause
 */

namespace izumi\spoolmailer;

use Swift_Events_EventListener;
use Swift_Message;
use Swift_Mime_SimpleMessage;
use Swift_Transport;
use yii\base\InvalidParamException;
use yii\base\NotSupportedException;
use yii\mail\MailerInterface;

/**
 * Sends Messages using the `MailerInterface`.
 *
 * @author <NAME> <<EMAIL>>
 */
class MailerTransport implements Swift_Transport
{
    /**
     * @var MailerInterface
     */
    protected $mailer;

    /**
     * FileTransport constructor.
     * @param MailerInterface $mailer
     */
    public function __construct(MailerInterface $mailer)
    {
        $this->mailer = $mailer;
    }

    /**
     * @inheritdoc
     */
    public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
    {
        if (!$message instanceof Swift_Message) {
            throw new InvalidParamException('The message should be an instance of "Swift_Message".');
        }
        $failedRecipients = (array) $failedRecipients;
        $importedMessage = new ImportedMessage($message);

        if ($this->mailer->send($importedMessage)) {
            return count($importedMessage->getTo());
        } else {
            $failedRecipients = (array) $importedMessage->getTo();
            return 0;
        }
    }

    /**
     * @inheritdoc
     */
    public function isStarted()
    {
        return true;
    }

    /**
     * @inheritdoc
     */
    public function start()
    {
    }

    /**
     * @inheritdoc
     */
    public function stop()<commit_msg>PHP 7.2: can't count null<commit_after><?php
/**
 * @link https://github.com/Izumi-kun/yii2-spoolmailer
 * @copyright Copyright (c) 2017 <NAME>
 * @license http://opensource.org/licenses/BSD-3-Clause
 */

namespace izumi\spoolmailer;

use Swift_Events_EventListener;
use Swift_Message;
use Swift_Mime_SimpleMessage;
use Swift_Transport;
use yii\base\InvalidParamException;
use yii\base\NotSupportedException;
use yii\mail\MailerInterface;

/**
 * Sends Messages using the `MailerInterface`.
 *
 * @author <NAME> <<EMAIL>>
 */
class MailerTransport implements Swift_Transport
{
    /**
     * @var MailerInterface
     */
    protected $mailer;

    /**
     * FileTransport constructor.
     * @param MailerInterface $mailer
     */
    public function __construct(MailerInterface $mailer)
    {
        $this->mailer = $mailer;
    }

    /**
     * @inheritdoc
     */
    public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null)
    {
        if (!$message instanceof Swift_Message) {
            throw new InvalidParamException('The message should be an instance of "Swift_Message".');
        }
        $failedRecipients = (array) $failedRecipients;
        $importedMessage = new ImportedMessage($message);

        if ($this->mailer->send($importedMessage)) {
            return count((array) $importedMessage->getTo());
        } else {
            $failedRecipients = (array) $importedMessage->getTo();
            return 0;
        }
    }

    /**
     * @inheritdoc
     */
    public function isStarted()
    {
        return true;
    }

    /**
     * @inheritdoc
     */
    public function start()
    {
    }

    /**
     * @inheritdoc
     */
    public function stop()
{'fraction_non_alphanumeric': 0.12287390029325514, 'fraction_numerical': 0.00469208211143695, 'mean_word_length': 2.5347150259067357, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 2, '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': '7522484', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1017, 'n_words': 212}