*/ class Options implements \App\Engine\IOptions { /** * Store variables for use in templates. * * @var array */ protected $variables; /** * Store the parameters we send to cloudformation. * * @var array */ protected $parameters; public function __construct() { $this->variables = []; $this->parameters = []; } /** * Set all variables. * * @param array $variables * @return void */ public function setVariables(array $variables): void { $this->variables = $variables; } /** * Retrieve all variables. * * @return array */ public function getVariables(): array { return $this->variables; } /** * Retrieve the value of a single variable. * * @param string $name * @throws \Exception if variable does not exist * @return mixed */ public function getVariable(string $name) { if (!isset($this->variables[$name])) { throw new \Exception('Unset variable: '.$name); } return $this->variables[$name]; } /** * Set a single variable. * * @param string $name * @param mixed $value * @return void */ public function setVariable(string $name, $value): void { $this->variables[$name] = $value; } /** * Check if a variable exists. * * @param string $name * @return bool */ public function hasVariable(string $name): bool { return isset($this->variables[$name]); } /** * Set all parameters. * * @param array $parameters * @return void */ public function setParameters(array $parameters): void { $this->parameters = $parameters; } /** * Retrieve all parameters. * * @return array */ public function getParameters(): array { return $this->parameters; } /** * Retrieve the value of a single parameter. * * @param string $name * @throws \Exception if parameter does not exist * @return mixed */ public function getParameter(string $name) { if (!isset($this->parameters[$name])) { throw new \Exception('Unset parameter: '.$name); } return $this->parameters[$name]; } /** * Set a single parameter. * * @param string $name * @param mixed $value * @return void */ public function setParameter(string $name, $value): void { $this->parameters[$name] = $value; } /** * Check if a parameter exists. * * @param string $name * @return bool */ public function hasParameter(string $name): bool { return isset($this->parameters[$name]); } }