<?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 TextFieldEntity extends FieldEntity
{
  use PlaceholderTraits, ReadonlyDisabledTraits, AppendPrependTraits;

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

  protected FieldTypeEnum $type = FieldTypeEnum::Text;

  protected ?int $maxLength = null;

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

    return $array;
  }
}
