<?php

namespace Src\Common\Dto\Object;

class TreeSelectObject extends AbstractObject {

    protected ?string $value = null;

    protected string $type = self::TREE_SELECT_TYPE;

    protected array $itemsData = [];

    public function getAttributes()
    {
        return [
            'value' => $this->value ?? '',
        ];
    }

    public function getJson()
    {
        return [
            'type' => $this->type,
            'composite' => false,
            'description' => $this->getTitle(),
            'value' => $this->value,
            'errors' => $this->errors,
            'items' => $this->itemsData,
        ];
    }

    public function loadAttributes(array $attrs)
    {
        $this->value = $attrs['value'];
    }

    public function getValue()
    {
        return $this->value;
    }

    public function setValue($value): void
    {
        $this->value = $value;
    }

    public function setItems(array $items): void
    {
        $this->itemsData = $items;
    }

}