<?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\FieldEntity;
use AuxCF\Entities\Settings\Enum\IntSwitchEnum;
use AuxCF\Entities\Settings\Traits\EnumPropertyTraits;

class RadioFieldEntity extends FieldEntity
{
  use ChoicesFieldTraits, EnumPropertyTraits, AllowNullTraits;

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

  protected FieldTypeEnum $type = FieldTypeEnum::Radio;

  protected IntSwitchEnum $otherChoice = IntSwitchEnum::Off;

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

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

    return $array;
  }
}
