<commit_before><?php

namespace Ddeboer\Imap;

class Message extends Message\Part
{
    protected $stream;
    protected $id;
    protected $headers;
    protected $parts;
    protected $body;

    public function __construct($stream, $messageNumber)
    {
        $this->stream = $stream;
        $this->messageNumber = $messageNumber;

        $this->loadStructure();
    }

    /**
     * Get message id
     *
     * A unique message id in the form <...>
     *
     * @return string
     */
    public function getId()
    {
        return $this->getHeaders()->get('message_id');
    }

    /**
     * Get sender
     *
     * @return EmailAddress
     */
    public function getFrom()
    {
        return $this->getHeaders()->get('from');
    }

    /**
     * Get recipients
     *
     * @return EmailAddress[]
     */
    public function getTo()
    {
        return $this->getHeaders()->get('to');
    }

    /**
     * Get message number
     *
     * @return int
     */
    public function getNumber()
    {
        return $this->getHeaders()->get('msgno');
    }

    /**
     * Get date
     *
     * @return \DateTime
     */
    public function getDate()
    {
        return $this->getHeaders()->get('date');
    }

    public function getSize()
    {
        return $this->getHeaders()->get('size');
    }

    public function isAnswered()
    {
        return $this->getHeaders()->get('answered');
    }

    public function isDeleted()
    {
        return $this->getHeaders()->get('deleted');
    }

    public function isDraft()
    {
        return $this->getHeaders()->get('draft');
    }

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

    /**
     *
     * @return HeaderCollection
     */
    public function getHeaders()
    {
        if (null === $this->headers) {
            $this->headers = new HeaderCollection(\imap_header($this->stream, $this->number));
        }

        return $this->headers;
    }

    /**
     * Get an array of all parts for this message
     *
     * @return Message\Part[]
     */
    public function getParts()
    {
        return $this->parts;
    }

    public function getBodyHtml()
    {
        $parts = $this->getParts();

        return $parts[1]->getContent();
    }
<commit_msg>Add doc, simplify message number getter<commit_after><?php

namespace Ddeboer\Imap;

class Message extends Message\Part
{
    protected $stream;
    protected $id;
    protected $headers;
    protected $parts;
    protected $body;

    public function __construct($stream, $messageNumber)
    {
        $this->stream = $stream;
        $this->messageNumber = $messageNumber;

        $this->loadStructure();
    }

    /**
     * Get message id
     *
     * A unique message id in the form <...>
     *
     * @return string
     */
    public function getId()
    {
        return $this->getHeaders()->get('message_id');
    }

    /**
     * Get message sender (from headers)
     *
     * @return EmailAddress
     */
    public function getFrom()
    {
        return $this->getHeaders()->get('from');
    }

    /**
     * Get message recipients (from headers)
     *
     * @return EmailAddress[]
     */
    public function getTo()
    {
        return $this->getHeaders()->get('to');
    }

    /**
     * Get message number (from headers)
     *
     * @return int
     */
    public function getNumber()
    {
        return $this->messageNumber;
    }

    /**
     * Get date (from headers)
     *
     * @return \DateTime
     */
    public function getDate()
    {
        return $this->getHeaders()->get('date');
    }

    /**
     * Get message size (from headers)
     *
     * @return int
     */
    public function getSize()
    {
        return $this->getHeaders()->get('size');
    }

    /**
     * Get message answered flag value (from headers)
     *
     * @return boolean
     */
    public function isAnswered()
    {
        return $this->getHeaders()->get('answered');
    }

    /**
     * Get message deleted flag value (from headers)
     *
     * @return boolean
     */
    public function isDeleted()
    {
        return $this->getHeaders()->get('deleted');
    }

    /**
     * Get message draft flag value (from headers)
     *
     * @return boolean
     */
    public function isDraft()
    {
        return $this->getHeaders()->get('draft');
    }

    /**
     * Get message subject (from headers)
     *
     * @return string
     */
    public function getSubject()
    {
        return $this->getHeaders()->get('subject');
    }

    /**
     * Get message headers
     *
     * @return Message\Headers
     */
    public function getHeaders()
    {
        if (null === $this->headers) {
            // \imap_header is much faster than \imap_fetchheader
            // \imap_header returns only a subset of all mail headers,
            // but it does include the message flags.
            $headers = \imap_header($this->stream, $this->messageNumber);
            $this->headers = new Message\Headers($headers);
        }

        return $this->headers;
    }

    /**
     * Get an array of all parts for this message
     *
     * @return Message\Part[]
     */
    public function getParts()
    {
        return $this->parts;
    }

    public function getBodyHtml()
    {
        $parts = $this->getParts();

        return $parts[1]->getContent();
    }

{'fraction_non_alphanumeric': 0.14003325327914282, 'fraction_numerical': 0.0003694808793644929, 'mean_word_length': 1.8022774327122153, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 66, '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': '3802222', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1544, 'n_words': 367}