1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<?php
/**
* Created by PhpStorm.
* Copyright: Bertschi AG, 2016
* User: jbaumann
* File: CommandInvoker.php
* Date: 11.01.2016
* Time: 08:49
*/
namespace JRA\Commands\Invokers;
use JRA\Abstracts\AbstractCommand;
class CommandInvoker
{
/**
* The command which should be executed.
*
* @var AbstractCommand
*/
protected $_command;
/**
* The response of the command.
*
* @var string
*/
protected $_contents;
/**
* Subscribes the command
*
* @param AbstractCommand $pCommand
*/
public function setCommand(AbstractCommand $pCommand)
{
$this->_command = $pCommand;
}
/**
* Starts the processing of the command
*/
public function run()
{
$this->_command->process();
$this->_contents = $this->_command->getResponse();
}
/**
* Returns the response of the command.
*
* @return string
*/
public function getContents()
{
return $this->_contents;
}
}