<?php

namespace Plainwork\Ui\Renderer;

use Plainwork\Ui\Ui;
use Plainwork\Ui\Component\FlashMessage;
use Plainwork\Ui\Component\HtmlElement;
use Plainwork\Ui\Component\Table;

final class FlashMessageRenderer
{
    public $ui = Ui::class;

    public function __invoke(FlashMessage $el)
    {
        $ret = [];

        $message = $el->getMessage();

        $ret = new HtmlElement('div', $message);
        $ret->withAttr('class', 'pw-msg');
        if ($el->isError()) {
            $ret->withAttr('class', 'pw-msg-error');
        } else {
            $ret->withAttr('class', 'pw-msg-success');
        }

        return $ret;
    }
}
