<?php

namespace Plainwork\Ui\Component;

final class TableCell extends AbstractTag
{
    private bool $isHead = false;
    private float $width = 0;
    private bool $isScopeRow = false;
    private bool $isDanger = false;

    public function __construct($content = '')
    {
        $this->setContent($content);
    }

    public function getContent()
    {
        return current($this->getChildren());
    }

    public function setScopeRow(bool $on = true): self
    {
        $this->isScopeRow = $on;

        return $this;
    }

    public function isScopeRow(): bool
    {
        return $this->isScopeRow;
    }

    public function setHead(bool $on = true): self
    {
        $this->isHead = $on;

        return $this;
    }

    public function isHead(): bool
    {
        return $this->isHead;
    }

    public function setWidth(float $w): self
    {
        if (($w < 0) or ($w > 12)) {
            throw new \InvalidArgumentException('table column width must be from 0 to 12');
        }
        $this->width = $w;

        return $this;
    }

    public function getWidth(): float
    {
        return $this->width;
    }

    public function setDanger(bool $on = true): self
    {
        $this->isDanger = $on;

        return $this;
    }

    public function isDanger(): bool
    {
        return $this->isDanger;
    }
}
