<?php
declare(strict_types=1);

namespace AuxCF\Entities\Field;

use AuxCF\Entities\Field\Enum\FieldTypeEnum;
use AuxCF\Entities\Field\Traits\AppendPrependTraits;
use AuxCF\Entities\Field\Traits\PlaceholderTraits;
use AuxCF\Entities\Field\Traits\ReadonlyDisabledTraits;
use AuxCF\Entities\FieldEntity;

class NumberFieldEntity extends FieldEntity
{
  use PlaceholderTraits, ReadonlyDisabledTraits, AppendPrependTraits;

  protected static array $arrayPropertiesMethods = [
    'getPlaceholderArray',
    'getAppendPrependArray',
    'getReadonlyDisabledArray',
  ];

  protected FieldTypeEnum $type = FieldTypeEnum::Number;

  protected ?int $min = null;
  protected ?int $max = null;
  protected ?int $step = null;

  public function getFieldArray(): array
  {
    $array = [
      'min' => is_null($this->min) ? '' : $this->min,
      'max' => is_null($this->max) ? '' : $this->max,
      'step' => is_null($this->step) ? '' : $this->step,
    ];

    return $array;
  }
}
