<?php
declare(strict_types=1);

namespace AuxCF\Entities\Field\Traits;

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

trait AllowNullTraits
{
  use EnumPropertyTraits;

  protected IntSwitchEnum $allowNull = IntSwitchEnum::Off;

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

  protected function getAllowNullArray(): array
  {
    return [
      'allow_null' => $this->allowNull->value
    ];
  }
}
