<?php
declare(strict_types=1);

namespace AuxCF\Entities\Field;

use AuxCF\Entities\Field\Enum\DateFieldFormatEnum;
use AuxCF\Entities\Field\Enum\FieldTypeEnum;
use AuxCF\Entities\FieldEntity;
use AuxCF\Entities\Settings\Traits\EnumPropertyTraits;

class DatetimeFieldEntity extends FieldEntity
{
  use EnumPropertyTraits;

  protected FieldTypeEnum $type = FieldTypeEnum::DatePicker;

  protected DateFieldFormatEnum $returnFormat = DateFieldFormatEnum::DEFAULT;
  protected DateFieldFormatEnum $displayFormat = DateFieldFormatEnum::DEFAULT;

  public function setDisplayFormat(string|DateFieldFormatEnum $displayFormat): self
  {
    $this->setEnumProperty(DateFieldFormatEnum::class, $displayFormat, 'display_format');
    return $this;
  }

  public function setReturnFormat(string|DateFieldFormatEnum $returnFormat): self
  {
    $this->setEnumProperty(DateFieldFormatEnum::class, $returnFormat, 'return_format');
    return $this;
  }

  public function getFieldArray(): array
  {
    $array = [
      'display_format' => $this->displayFormat->value,
      'return_format' => $this->returnFormat->value,
      'first_day' => 0,
    ];

    return $array;
  }
}
