<?php

namespace Plainwork\Ui\Renderer;

use Plainwork\Ui\Component\Card;
use Plainwork\Ui\Component\Table;

final class CardRenderer
{
    public function __invoke(Card $el)
    {
        $ret = new Table();

        $content = $el->getContent();
        $content = is_array($content) ? $content : [$content];

        $ii = 1;
        foreach ($content as $c) {
            $ret->withCell($ii, 1)->setContent($c);
            ++$ii;
        }


        $attr = $el->getAttr();
        foreach ($attr as $k => $v) {
            $ret->withCell(1, 1)->withAttr($k, $v);
        }

        return $ret;
    }
}
