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

/**
 * The base class from where all Sabre 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;
	}

	public function getTransaction()
	{
		return $this->transaction;
	}

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

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