<commit_before><?php
/**
 * @file
 */

namespace CultuurNet\UDB3\EventExport\Notification\Swift;


use CultuurNet\UDB3\EventExport\EventExportResult;
use CultuurNet\UDB3\EventExport\Notification\BodyFactoryInterface;
use CultuurNet\UDB3\EventExport\Notification\SubjectFactoryInterface;

class DefaultMessageFactory implements MessageFactoryInterface
{
    /**
     * @var BodyFactoryInterface
     */
    private $plainTextMailFormatter;

    /**
     * @var BodyFactoryInterface
     */
    private $htmlMailFormatter;

    /**
     * @var SubjectFactoryInterface
     */
    private $subjectFormatter;

    /**
     * @var string
     */
    private $senderAddress;

    /**
     * @var string
     */
    private $senderName;

    /**
     * @param BodyFactoryInterface $plainTextMailFormatter
     * @param BodyFactoryInterface $htmlMailFormatter
     * @param SubjectFactoryInterface $subjectFormatter
     * @param string $senderAddress
     * @param string $senderName
     */
    public function __construct(
        BodyFactoryInterface $plainTextMailFormatter,
        BodyFactoryInterface $htmlMailFormatter,
        SubjectFactoryInterface $subjectFormatter,
        $senderAddress,
        $senderName
    )
    {
        $this->plainTextMailFormatter = $plainTextMailFormatter;
        $this->htmlMailFormatter = $htmlMailFormatter;
        $this->senderAddress = $senderAddress;
        $this->senderName = $senderName;
        $this->subjectFormatter = $subjectFormatter;
    }

    /**
     * @param string $address
     * @return \Swift_Message
     */
    public function createMessageFor($address, EventExportResult $eventExportResult)
    {
        $message = new \Swift_Message($this->subjectFormatter->getSubjectFor($eventExportResult));
        $message->setBody(
            $this->htmlMailFormatter->getBodyFor(
                $eventExportResult
            ),
            'text/html'
        );
        $message->addPart(
            $this->plainTextMailFormatter->getBodyFor(
                $eventExportResult
            ),
            'text/plain'
        );

        $message->addTo($address);

        $message->setSender($this->senderAddress, $this->senderName);
        $message->setFrom($this->senderAddress, $this->senderName);

        return $message;
    }
}<commit_msg>III-24: Use 'factory' instead of 'formatter'<commit_after><?php
/**
 * @file
 */

namespace CultuurNet\UDB3\EventExport\Notification\Swift;


use CultuurNet\UDB3\EventExport\EventExportResult;
use CultuurNet\UDB3\EventExport\Notification\BodyFactoryInterface;
use CultuurNet\UDB3\EventExport\Notification\SubjectFactoryInterface;

class DefaultMessageFactory implements MessageFactoryInterface
{
    /**
     * @var BodyFactoryInterface
     */
    private $plainTextBodyFactory;

    /**
     * @var BodyFactoryInterface
     */
    private $htmlBodyFactory;

    /**
     * @var SubjectFactoryInterface
     */
    private $subjectFactory;

    /**
     * @var string
     */
    private $senderAddress;

    /**
     * @var string
     */
    private $senderName;

    /**
     * @param BodyFactoryInterface $plainTextBodyFactory
     * @param BodyFactoryInterface $htmlBodyFactory
     * @param SubjectFactoryInterface $subjectFactory
     * @param string $senderAddress
     * @param string $senderName
     */
    public function __construct(
        BodyFactoryInterface $plainTextBodyFactory,
        BodyFactoryInterface $htmlBodyFactory,
        SubjectFactoryInterface $subjectFactory,
        $senderAddress,
        $senderName
    )
    {
        $this->plainTextBodyFactory = $plainTextBodyFactory;
        $this->htmlBodyFactory = $htmlBodyFactory;
        $this->senderAddress = $senderAddress;
        $this->senderName = $senderName;
        $this->subjectFactory = $subjectFactory;
    }

    /**
     * @param string $address
     * @return \Swift_Message
     */
    public function createMessageFor($address, EventExportResult $eventExportResult)
    {
        $message = new \Swift_Message($this->subjectFactory->getSubjectFor($eventExportResult));
        $message->setBody(
            $this->htmlBodyFactory->getBodyFor(
                $eventExportResult
            ),
            'text/html'
        );
        $message->addPart(
            $this->plainTextBodyFactory->getBodyFor(
                $eventExportResult
            ),
            'text/plain'
        );

        $message->addTo($address);

        $message->setSender($this->senderAddress, $this->senderName);
        $message->setFrom($this->senderAddress, $this->senderName);

        return $message;
    }
}
{'fraction_non_alphanumeric': 0.10694955618099156, 'fraction_numerical': 0.002164970772894566, 'mean_word_length': 2.58974358974359, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '3520673', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1217, 'n_words': 201}