You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.4 KiB
85 lines
1.4 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Engine;
|
|
|
|
/**
|
|
* Options for controlling the Cfnpp compilation process.
|
|
*
|
|
* @author Adam Pippin <hello@adampippin.ca>
|
|
*/
|
|
class CfnppOptions implements IOptions
|
|
{
|
|
/**
|
|
* Store variables for use in templates.
|
|
*
|
|
* @var array<string,mixed>
|
|
*/
|
|
protected $variables;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->variables = [];
|
|
}
|
|
|
|
/**
|
|
* Set all variables.
|
|
*
|
|
* @param array<string,mixed> $variables
|
|
* @return void
|
|
*/
|
|
public function setVariables(array $variables): void
|
|
{
|
|
$this->variables = $variables;
|
|
}
|
|
|
|
/**
|
|
* Retrieve all variables.
|
|
*
|
|
* @return array<string,mixed>
|
|
*/
|
|
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]);
|
|
}
|
|
}
|
|
|