<?php
namespace ModulesAbstract\FluxRest\ResponseHandler\Operation;

/**
 * Abstract class for all response handlers
 * @author Lucian Sirbu
 *
 */
abstract class OperationAbstract
{
	public $action = null;

	/**
	 * Internal logger
	 * @var \Engine\Logger\BufferedPrintf
	 */
	protected $logger = null;

	/**
	 * The parent object
	 * @var \ModulesAbstract\FluxRest\FluXEmulator
	 */
	protected $FluXEmulator = null;

	/**
	 * Create a new operation
	 * @param \ModulesAbstract\FluxRest\FluXEmulator $FluXEmulator
	 * @param \Engine\Logger\GeneralAbstract $logger
	 */
	public function __construct(\ModulesAbstract\FluxRest\FluXEmulator $FluXEmulator, \Engine\Logger\GeneralAbstract $logger)
	{
		$this->action = stripClassNamespace(get_class($this));
		$this->logger = $logger;
		$this->FluXEmulator = $FluXEmulator;
	}

	/**
	 * Handle the client response
	 * @return null|array
	 */
	abstract public function handle();

	/**
	 * Simplified response handling, ignores part of the response
	 */
	public function handleAndGetResponse()
	{
		return $this->handle()[1];
	}
}
