<commit_before><?php
namespace Concrete\Core\Mail;

use Config;
use Concrete\Core\Logging\GroupLogger;
use Zend\Mail\Message;
use Zend\Mail\Transport\Sendmail as SendmailTransport;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Mime;
use Zend\Mime\Part as MimePart;
use Exception;
use Monolog\Logger;

class Service
{
    protected $headers;
    protected $to;
    protected $replyto;
    protected $cc;
    protected $bcc;
    protected $from;
    protected $data;
    protected $subject;
    protected $attachments;
    protected $template;
    protected $body;
    protected $bodyHTML;
    protected $testing;

    public function __construct()
    {
        $this->reset();
    }

    /**
     * this method is called by the Loader::helper to clean up the instance of this object
     * resets the class scope variables.
     */
    public function reset()
    {
        $this->headers = array();
        $this->to = array();
        $this->replyto = array();
        $this->cc = array();
        $this->bcc = array();
        $this->from = array();
        $this->data = array();
        $this->subject = '';
        $this->attachments = array();
        $this->template = '';
        $this->body = false;
        $this->bodyHTML = false;
        $this->testing = false;
    }

    public static function getMailerObject()
    {
        $response = array();
        $response['mail'] = new Message();
        $response['mail']->setEncoding(APP_CHARSET);

        if (strcasecmp(Config::get('concrete.mail.method'), 'smtp') == 0) {
            $config = array(
                'host' => Config::get('concrete.mail.methods.smtp.server'),
            );

            $username = Config::get('concrete.mail.methods.smtp.username');
            $password = Config::get('concrete.mail.methods.smtp.password');
            if ($username != '') {
                $config['connection_class'] = 'login';
                $config['connection_config'] = array();
                $config['connection_config']['username'] = $username;
                $config['connection_config']['password'] = <PASSWORD>;
            }

            $port = Config::get('concrete.mail.methods.smtp.port', '');
            if ($port != '') {
                $config['port'] = $port;
            }

            $encr = Config::get('concrete.mail.methods.smtp.encryption', '');
            if ($encr != '') {
                $config['connection_config']['ssl'] = $encr;
            }
            $transport = new SmtpTransport();
            $options = new SmtpOptions($config);
            $transport->setOptions($options);
            $response['transport'] = $transport;
        } else {
            $response['transport'] = new SendmailTransport();
        }

        return $response;
    }

    /**
     * Adds a parameter to a mail template.
     *
     * @param string $key
     * @param string $val
     */
    public function addParameter($key, $val)
    {
        $this->data[$key] = $val;
    }

    /**
     * Add attachment to send with an email.
     *
     * Sample Code:
     * $attachment = $mailHelper->addAttachment($fileObject);
     * $attachment->filename = "CustomFilename";
     * $mailHelper->send();
     *
     * @param \Concrete\Core\File\File $fob File to attach
     *
     * @return \StdClass Pointer to the attachment
     *
     * @throws \Exception
     */
    public function addAttachment(\Concrete\Core\File\File $fob)
    {

        // Get file version.
        $fv = $fob->getVersion();
<commit_msg>Update docblock on Mail service addParameter method to reflect that it accepts any parameter type<commit_after><?php
namespace Concrete\Core\Mail;

use Config;
use Concrete\Core\Logging\GroupLogger;
use Zend\Mail\Message;
use Zend\Mail\Transport\Sendmail as SendmailTransport;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mail\Transport\SmtpOptions;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Mime;
use Zend\Mime\Part as MimePart;
use Exception;
use Monolog\Logger;

class Service
{
    protected $headers;
    protected $to;
    protected $replyto;
    protected $cc;
    protected $bcc;
    protected $from;
    protected $data;
    protected $subject;
    protected $attachments;
    protected $template;
    protected $body;
    protected $bodyHTML;
    protected $testing;

    public function __construct()
    {
        $this->reset();
    }

    /**
     * this method is called by the Loader::helper to clean up the instance of this object
     * resets the class scope variables.
     */
    public function reset()
    {
        $this->headers = array();
        $this->to = array();
        $this->replyto = array();
        $this->cc = array();
        $this->bcc = array();
        $this->from = array();
        $this->data = array();
        $this->subject = '';
        $this->attachments = array();
        $this->template = '';
        $this->body = false;
        $this->bodyHTML = false;
        $this->testing = false;
    }

    public static function getMailerObject()
    {
        $response = array();
        $response['mail'] = new Message();
        $response['mail']->setEncoding(APP_CHARSET);

        if (strcasecmp(Config::get('concrete.mail.method'), 'smtp') == 0) {
            $config = array(
                'host' => Config::get('concrete.mail.methods.smtp.server'),
            );

            $username = Config::get('concrete.mail.methods.smtp.username');
            $password = Config::get('concrete.mail.methods.smtp.password');
            if ($username != '') {
                $config['connection_class'] = 'login';
                $config['connection_config'] = array();
                $config['connection_config']['username'] = $username;
                $config['connection_config']['password'] = $password;
            }

            $port = Config::get('concrete.mail.methods.smtp.port', '');
            if ($port != '') {
                $config['port'] = $port;
            }

            $encr = Config::get('concrete.mail.methods.smtp.encryption', '');
            if ($encr != '') {
                $config['connection_config']['ssl'] = $encr;
            }
            $transport = new SmtpTransport();
            $options = new SmtpOptions($config);
            $transport->setOptions($options);
            $response['transport'] = $transport;
        } else {
            $response['transport'] = new SendmailTransport();
        }

        return $response;
    }

    /**
     * Adds a parameter to a mail template.
     *
     * @param string $key
     * @param mixed $val
     */
    public function addParameter($key, $val)
    {
        $this->data[$key] = $val;
    }

    /**
     * Add attachment to send with an email.
     *
     * Sample Code:
     * $attachment = $mailHelper->addAttachment($fileObject);
     * $attachment->filename = "CustomFilename";
     * $mailHelper->send();
     *
     * @param \Concrete\Core\File\File $fob File to attach
     *
     * @return \StdClass Pointer to the attachment
     *
     * @throws \Exception
     */
    public function addAttachment(\Concrete\Core\File\File $fob)
    {

        // Get file version.
        $fv = $fob->getVersion();

{'fraction_non_alphanumeric': 0.14550700741962078, 'fraction_numerical': 0.0002748007694421544, 'mean_word_length': 2.136148211977596, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 48, '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': '7568891', 'n_tokens_mistral': 2124, 'n_tokens_neox': 2057, 'n_words': 468}