<?php

namespace Plainwork\Ui\Component;

final class Grid extends AbstractTag
{
    private string $scheme = '1-3-1';
    private array $items = [];
    private int $spacing = 2;

    public function __construct(string $scheme = '131', array $items = [])
    {
        $this->scheme = $scheme;
        $this->items = $items;
    }

    public function getScheme(): string
    {
        return $this->scheme;
    }

    public function add($item): self
    {
        $this->items[] = $item;

        return $this;
    }

    public function getItems(): array
    {
        return $this->items;
    }

    public function setSpacing(int $v): self
    {
        if ($v < 0) {
            $v = 0;
        }
        if ($v > 3) {
            $v = 3;
        }
        $this->spacing = $v;

        return $this;
    }

    public function getSpacing(): int
    {
        return $this->spacing;
    }

    public function smallSpacing(): self
    {
        return $this->setSpacing(1);
    }

    public function largeSpacing(): self
    {
        return $this->setSpacing(3);
    }

    public function noSpacing(): self
    {
        return $this->setSpacing(0);
    }
}
