<?php
namespace Modules\Admin\ImportEntities\Model;

abstract class ImportAbstract
{

	/**
	 *
	 * @var array
	 */
	protected $fileData = [];

	/**
	 *
	 * @var array
	 */
	protected $fields = [];

	/**
	 * The date format used for importing the entity
	 * @var String
	 */
	protected $dateFormat = null;

	/**
	 * This flag determines if the entity use date format
	 * @var Boolean
	 */
	protected $useDateFormat = FALSE;

	/**
	 *
	 * @param array $fileData
	 */
	public function setFileContent($fileData)
	{
		$this->fileData = $fileData;
	}


	/**
	 * shows if the entity uses date format
	 */
	public function useDateFormat()
	{
		return $this->useDateFormat;
	}

	/**
	 * Set the date format used to import this type of entity
	 * @param String $dateFormat
	 */
	public function setDateFormat($dateFormat)
	{
		$this->dateFormat = $dateFormat;
	}

	/**
	 * Returns the date format
	 */
	public function getDateFormat()
	{
		return $this->dateFormat;
	}

	/**
	 *
	 */
	abstract public function process();

	/**
	 *
	 */
	public function getEntityFields()
	{
		return $this->fields;
	}

	/**
	 *
	 * @param \App\MessagesCollector $messagesCollector
	 * @return NULL
	 */
	public function checkContent(\App\MessagesCollector $messagesCollector)
	{
		return null;
	}

	/**
	 * Analyze the content of the file
	 */
	public function analyze()
	{
		return null;
	}


	/**
	 * Safely applies upper-case on strings that were already htmlClean-ed withour transforming &amp; to &AMP; (same for lg, gt and quot).
	 * @param string $text
	 */
	protected function safeUppercaseHtmlCleanedText(string $text) :string
	{
		return htmlClean( mb_strtoupper( htmlUnclean($text) ) );
	}

}