<commit_before><?php

namespace Herald\Client;

class Message implements MessageInterface
{
    private $messageTemplate;
    private $toAddress;
    private $data;
    private $attachments = array();

    public function getTemplate()
    {
        return $this->messageTemplate;
    }

    public function setTemplate($template)
    {
        $this->messageTemplate = $template;

        return $this;
    }

    public function getToAddress()
    {
        return $this->toAddress;
    }
    public function setToAddress($toAddress, $name = null)
    {
        $this->toAddress = $toAddress;
        if ($name) {
            $this->toAddress .= ':'.$name;
        }

        return $this;
    }

    public function setData($key, $value)
    {
        $this->data[$key] = $value;

        return $this;
    }

    public function getData()
    {
        return $this->data;
    }

    public function serializeData()
    {
        $data = array('values' => $this->data, 'attachments' => array());
        $attachments = $this->getAttachments();
        foreach ($attachments as $a) {
            $data['attachments'][] = array(
                'name' => $a['name'],
                'data' => base64_encode(file_get_contents($a['path'])),
            );
        }

        return json_encode($data);
        // $o = '';
        // foreach ((array) $this->data as $key => $value) {
        //     $o .= $key.':'.$value.',';<commit_msg>support subject and body override<commit_after><?php

namespace Herald\Client;

class Message implements MessageInterface
{
    private $messageTemplate;
    private $toAddress;
    private $data;
    private $attachments = array();
    private $subject;
    private $body;

    public function getTemplate()
    {
        return $this->messageTemplate;
    }

    public function setTemplate($template)
    {
        $this->messageTemplate = $template;

        return $this;
    }

    public function getToAddress()
    {
        return $this->toAddress;
    }
    public function setToAddress($toAddress, $name = null)
    {
        $this->toAddress = $toAddress;
        if ($name) {
            $this->toAddress .= ':'.$name;
        }

        return $this;
    }

    public function getSubject()
    {
        return $this->subject;
    }

    public function setSubject($subject)
    {
        $this->subject = $subject;

        return $this;
    }

    public function getBody()
    {
        return $this->body;
    }

    public function setBody($body)
    {
        $this->body = $body;

        return $this;
    }

    public function setData($key, $value)
    {
        $this->data[$key] = $value;

        return $this;
    }

    public function getData()
    {
        return $this->data;
    }

    public function serializeData()
    {
        $data = array(
            'values' => $this->data,
            'attachments' => array(),
            'subject' => $this->subject,
            'body' => $this->body,
        );
        $attachments = $this->getAttachments();
        foreach ($attachments as $a) {
            $data['attachments'][] = array(
                'name' => $a['name'],
                'data' => base64_encode(file_get_contents($a['path'])),
            );
        }

        return json_encode($data);
        // $o = '';
        // foreach ((array) $this->data as $key => $value) {
        //     $o .= $key.':'.$value.',';
{'fraction_non_alphanumeric': 0.14717978848413632, 'fraction_numerical': 0.0011750881316098707, 'mean_word_length': 1.858942065491184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '2045311', 'n_tokens_mistral': 1007, 'n_tokens_neox': 977, 'n_words': 216}