<commit_before><?php

namespace NTI\EmailBundle\Service;

use Doctrine\ORM\EntityManagerInterface;
use NTI\EmailBundle\Entity\Email;
use NTI\EmailBundle\Entity\Smtp;
use NTI\EmailBundle\Utilities\StringUtilities;
use Swift_FileSpool;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Mailer {

    /** @var ContainerInterface $container */
    private $container;

    /** @var EngineInterface $templating */
    private $templating;
    
    /** @var bool $devMode */
    private $devMode = false;

    /** @var string $devTo */
    private $devTo;
    /** @var string $devCc */
    private $devCc;
    /** @var string $devBcc */
    private $devBcc;

    public function __construct(ContainerInterface $container, EngineInterface $templating) {
        $this->container = $container;
        $this->templating = $templating;

        $devMode = $this->container->getParameter('nti_email.dev_mode');
        $this->devMode = is_array($devMode) && isset($devMode["enabled"]) && $devMode["enabled"];
        if($this->devMode) {
            $this->devTo = $devMode["to"];
            $this->devCc = $devMode["cc"];
            $this->devBcc = $devMode["bcc"];
        }
    }

    /**
     * Send an email with a twig template
     *
     * @param $from
     * @param $to
     * @param $cc
     * @param $bcc
     * @param $subject
     * @param $template
     * @param array $parameters
     * @param array $attachments
     * @return bool
     */
    public function sendFromTemplate($from, $to, $cc, $bcc, $subject, $template, $parameters = array(), $attachments = array()) {
        $html = $this->templating->render($template, $parameters);
        return $this->sendEmail($from, $to, $cc, $bcc, $subject, $html, $attachments);
    }

    /**
     * Send an email with a twig template<commit_msg>Additional verification for dev mode<commit_after><?php

namespace NTI\EmailBundle\Service;

use Doctrine\ORM\EntityManagerInterface;
use NTI\EmailBundle\Entity\Email;
use NTI\EmailBundle\Entity\Smtp;
use NTI\EmailBundle\Utilities\StringUtilities;
use Swift_FileSpool;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Mailer {

    /** @var ContainerInterface $container */
    private $container;

    /** @var EngineInterface $templating */
    private $templating;
    
    /** @var bool $devMode */
    private $devMode = false;

    /** @var string $devTo */
    private $devTo;
    /** @var string $devCc */
    private $devCc;
    /** @var string $devBcc */
    private $devBcc;

    public function __construct(ContainerInterface $container, EngineInterface $templating) {
        $this->container = $container;
        $this->templating = $templating;

        $devMode = $this->container->getParameter('nti_email.dev_mode');
        $this->devMode = is_array($devMode) && isset($devMode["enabled"]) && $devMode["enabled"] === true;
        if($this->devMode) {
            $this->devTo = $devMode["to"];
            $this->devCc = $devMode["cc"];
            $this->devBcc = $devMode["bcc"];
        }
    }

    /**
     * Send an email with a twig template
     *
     * @param $from
     * @param $to
     * @param $cc
     * @param $bcc
     * @param $subject
     * @param $template
     * @param array $parameters
     * @param array $attachments
     * @return bool
     */
    public function sendFromTemplate($from, $to, $cc, $bcc, $subject, $template, $parameters = array(), $attachments = array()) {
        $html = $this->templating->render($template, $parameters);
        return $this->sendEmail($from, $to, $cc, $bcc, $subject, $html, $attachments);
    }

    /**
     * Send an email with a twig template
{'fraction_non_alphanumeric': 0.1447233606557377, 'fraction_numerical': 0.0, 'mean_word_length': 3.0216271884654993, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '3902789', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1197, 'n_words': 268}