HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/lcc.kaunokolegija.lt/wp-content/plugins/codepress-admin-columns/classes/Message.php
<?php

namespace AC;

use Exception;
use LogicException;

abstract class Message
{

    public const SUCCESS = 'updated'; // green
    public const ERROR = 'notice-error'; // red
    public const WARNING = 'notice-warning'; // yellow
    public const INFO = 'notice-info'; // blue

    protected $message;

    protected $type;

    protected $id = '';

    public function __construct(string $message, string $type = null)
    {
        if (null === $type) {
            $type = self::SUCCESS;
        }

        $this->type = $type;
        $this->message = trim($message);

        $this->validate();
    }

    protected function validate(): void
    {
        if (empty($this->message)) {
            throw new LogicException('Message cannot be empty');
        }
    }

    abstract public function render(): string;

    /**
     * Display self::render to the screen
     * @throws Exception
     */
    public function display(): void
    {
        echo $this->render();
    }

    public function get_message(): string
    {
        return $this->message;
    }

    public function get_type(): string
    {
        return $this->type;
    }

    public function set_type(string $type): self
    {
        $this->type = $type;

        return $this;
    }

    public function get_id(): string
    {
        return $this->id;
    }

    public function set_id(string $id): self
    {
        $this->id = $id;

        return $this;
    }
}