<?php

namespace domain\Ticket\TicketMessage;

use domain\Ticket\Ticket\Ticket;
use domain\User\User\User;
use domain\_\AbstractBuilder;

class TicketMessageBuilder extends AbstractBuilder
{
    public function instanciateTicketMessage(Ticket $ticket, User $user, string $message = ''): TicketMessage
    {
        $ticketMessage = new TicketMessage();

        $ticketMessage->populateTicket($ticket);
        $ticketMessage->populateUser($user);
        $ticketMessage->message = $message;

        return $ticketMessage;
    }

    public function createTicketMessage(Ticket $ticket, User $user, string $message): TicketMessage
    {
        $ticketMessage = $this->instanciateTicketMessage($ticket, $user, $message);
        $this->create($ticketMessage);

        return $ticketMessage;
    }
}