<?php

namespace kernel\modules\notification\contracts;

abstract class NotificationMessage
{
    protected array $channels = [];

    abstract public function getMessage(): string;
    abstract public function getSubject(): string;

    public function via(): array
    {
        return $this->channels;
    }

    public function addChannel(string $channel): void
    {
        if (!in_array($channel, $this->channels)) {
            $this->channels[] = $channel;
        }
    }

    public function toArray(): array
    {
        return [
            'message' => $this->getMessage(),
            'subject' => $this->getSubject(),
        ];
    }
}