<?php
namespace App\Galileo\StructureParser\Structures\Base;

/**
 * The base class from where all Galileo structure parsers will be extended
 * @author Lucian Sirbu
 */
abstract class Base extends \App\Utils\BaseParser\Structure\StructureParser\Structures\Base\Base
{
	protected $cachedResponse = null;

	/**
	 * Overrides the base function and implementes an auto-caching mechanism(calling the function twice will only lead to real data-extraction once)
	 * (non-PHPdoc)
	 * @see \App\Utils\BaseParser\Structure\StructureParser\Structures\Base\Base::getData()
	 */
	public function getData()
	{
		if ($this->cachedResponse===null) {
			$this->cachedResponse = $this->_getData();
		}
		return $this->cachedResponse;
	}

	protected function getTransactionDetails()
	{
		return $this->transaction->getTransactionDetails();
	}

	/**
	 * This is the function that the extending classes should implement
	 */
	abstract protected function _getData();
}
