<?php
namespace App\ImportedDocument;

abstract class EntityAbstract
{

	/**
	 * Validates each entity fields and if something wrong is found, add it to the internal messages.
	 * @param \App\MessagesCollector $messagesCollector
	 */
	abstract protected function validateEntityFields(\App\MessagesCollector $messagesCollector);

	/**
	 * functie apelata in entitatea de imp documents
	 * atasat error sau warning
	 */
	public function check()
	{

		$msgs = new \App\MessagesCollector();

		$this->validateEntityFields($msgs);

		if ($msgs->hasErrorOrWarning()) {
			throw new \App\MessagesException($msgs);
		}

		return $msgs;

	}
}
