<?php

namespace Eater\Glim\Model;

use Eater\Glim\Model\Base\EmailMessage as BaseEmailMessage;

/**
 * Skeleton subclass for representing a row from the 'email_message' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 */
class EmailMessage extends BaseEmailMessage
{
    public function getRecipientEmail()
    {
        return $this->getRecipientEmailAddress()->getAddress();
    }

    public function getRecipientName()
    {
        return $this->getRecipientEmailAddress()->getUserRelatedByOwner()->getUsername();
    }

    public function getSenderName() {
        $emailAddress = $this->getSenderEmailAddress();

        if ($emailAddress === null) {
            return 'Zer.ooo system';
        }

        return $emailAddress->getUserRelatedByOwner()->getUsername();
    }

    public function getSenderEmail() {
        $emailAddress = $this->getSenderEmailAddress();

        if ($emailAddress === null) {
            return 'info@zer.ooo';
        }

        return $emailAddress->getAddress();
    }
}
