<?php
declare(strict_types=1);

namespace AuxCF\Entities\Field\Traits;

use AuxCF\Entities\Settings\Enum\IntSwitchEnum;
use AuxCF\Entities\Settings\Traits\EnumPropertyTraits;

trait ReadonlyDisabledTraits
{
  use EnumPropertyTraits;

  protected IntSwitchEnum $readonly = IntSwitchEnum::Off;
  protected IntSwitchEnum $disabled = IntSwitchEnum::Off;

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

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

  protected function getReadonlyDisabledArray(): array
  {
    return [
      'readonly' => $this->readonly->value,
      'disabled' => $this->disabled->value,
    ];
  }
}
