<?php

namespace Shm\ShmAddons\EventTicketAddon\Types\HallType;

use Shm\Shm;
use Shm\ShmDB\mDB;
use Shm\ShmRPC\ShmRPCCodeGen\TSType;
use Shm\ShmTypes\BaseType;
use Traversable;

class HallSelector extends BaseType
{
    public string $type = 'hallSelector';


    public bool $compositeType = true;


    public $hallSelectorReverse = false;

    public $hallSelectorElements = [];



    public $hallSelectorHallUUID = null;

    public function setHallSelectorElements(array $elements): self
    {

        $data = [];
        //Проверка что в каждом элементе есть _id price color
        foreach ($elements as $element) {
            if (!isset($element['hallElement']) || !isset($element['price']) || !isset($element['color'])) {

                Shm::error('У элемента зала отсутствуют обязательные поля');
            }

            $data[] = [
                'hallElement' => (string) $element['hallElement'],
                'price' => (float) $element['price'],
                'color' => (string) $element['color'],
            ];
        }
        $this->hallSelectorElements = $data;
        return $this;
    }



    public function setHallSelectorHallUUID(string $hallUUID): self
    {
        $this->hallSelectorHallUUID = $hallUUID;
        return $this;
    }

    public function setHallSelectorReverse(bool $reverse): self
    {
        $this->hallSelectorReverse = $reverse;
        return $this;
    }
}
