<commit_before><?php
/**
 * @author <NAME> <<EMAIL>>
 */

namespace EnliteMail;

use Zend\Mail\Message;
use Zend\Mime\Mime;
use Zend\Mime\Part;
use Zend\View\Helper\HeadTitle;
use Zend\View\Model\ViewModel;
use Zend\View\Renderer\RendererInterface;
use Zend\Mime\Message as MimeMessage;

class Template
{

    /**
     * @var array
     */
    protected $variables = array();

    /**
     * @var RendererInterface
     */
    protected $renderer;

    /**
     * @var string
     */
    protected $template;

    /**
     * @param RendererInterface $renderer
     * @param string            $template
     */
    public function __construct(RendererInterface $renderer, $template)
    {
        $this->renderer = $renderer;
        $this->template = $template;
    }

    /**
     * @param string $key
     * @param string $value
     */
    public function setVariable($key, $value)
    {
        $this->variables[$key] = $value;
    }

    /**
     * @param Message $message
     * @return Message
     */
    public function render(Message $message)
    {
        $viewModel = new ViewModel($this->variables);
        $viewModel->setTemplate($this->template);

        /** @var HeadTitle $helper */
        $helper = $this->renderer->getHelperPluginManager()->get('HeadTitle');

        if (!$message->getBody()) {
            $message->setBody(new MimeMessage());
        }

        $text = new Part($message->getBodyText());
        $text->charset = 'UTF-8';
        $text->boundary = $message->getBody()->getMime()->boundary();
        $text->encoding = Mime::ENCODING_BASE64;
        $text->type = Mime::TYPE_HTML;

        $message->getBody()->addPart($this->renderer->render($viewModel));
        $message->setSubject($helper->renderTitle());

        return $message;
    }

}<commit_msg>fix problem with wrong mail part<commit_after><?php
/**
 * @author <NAME> <<EMAIL>>
 */

namespace EnliteMail;

use Zend\Mail\Message;
use Zend\Mime\Mime;
use Zend\Mime\Part;
use Zend\View\Helper\HeadTitle;
use Zend\View\Model\ViewModel;
use Zend\View\Renderer\RendererInterface;
use Zend\Mime\Message as MimeMessage;

class Template
{

    /**
     * @var array
     */
    protected $variables = array();

    /**
     * @var RendererInterface
     */
    protected $renderer;

    /**
     * @var string
     */
    protected $template;

    /**
     * @param RendererInterface $renderer
     * @param string            $template
     */
    public function __construct(RendererInterface $renderer, $template)
    {
        $this->renderer = $renderer;
        $this->template = $template;
    }

    /**
     * @param string $key
     * @param string $value
     */
    public function setVariable($key, $value)
    {
        $this->variables[$key] = $value;
    }

    /**
     * @param Message $message
     * @return Message
     */
    public function render(Message $message)
    {
        $viewModel = new ViewModel($this->variables);
        $viewModel->setTemplate($this->template);

        /** @var HeadTitle $helper */
        $helper = $this->renderer->getHelperPluginManager()->get('HeadTitle');

        if (!$message->getBody()) {
            $message->setBody(new MimeMessage());
        }

        $text = new Part($this->renderer->render($viewModel));
        $text->charset = 'UTF-8';
        $text->boundary = $message->getBody()->getMime()->boundary();
        $text->encoding = Mime::ENCODING_BASE64;
        $text->type = Mime::TYPE_HTML;

        $message->getBody()->addPart($text);
        $message->setSubject($helper->renderTitle());

        return $message;
    }

}
{'fraction_non_alphanumeric': 0.1578216171158655, 'fraction_numerical': 0.0016671297582661851, 'mean_word_length': 2.3866415804327374, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 58, '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': '5257777', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1064, 'n_words': 207}