<?php
declare(strict_types=1);

namespace AuxCF\Entities\Field;

use AuxCF\Entities\Field\Enum\FieldTypeEnum;
use AuxCF\Entities\Field\Traits\AllowNullTraits;
use AuxCF\Entities\Field\Traits\ChoicesFieldTraits;
use AuxCF\Entities\Field\Traits\PlaceholderTraits;
use AuxCF\Entities\Field\Traits\UiSwitchTraits;
use AuxCF\Entities\FieldEntity;
use AuxCF\Entities\Settings\Enum\IntSwitchEnum;

class SelectFieldEntity extends FieldEntity
{
  use ChoicesFieldTraits, UiSwitchTraits, AllowNullTraits, PlaceholderTraits;

  protected static array $arrayPropertiesMethods = [
    'getAllowNullArray',
    'getUiArray',
    'getPlaceholderArray',
    'getChoicesArray',
  ];

  protected FieldTypeEnum $type = FieldTypeEnum::Select;

  protected IntSwitchEnum $multiple = IntSwitchEnum::Off;

  public function setMultiple(int|IntSwitchEnum $multiple): self
  {
    $this->setEnumProperty(IntSwitchEnum::class, $multiple, 'multiple');
    return $this;
  }

  public function getFieldArray(): array
  {
    $array = [
      'multiple' => $this->multiple->value,
    ];

    return $array;
  }
}
