diff --git a/app/Commands/Stack/Compile.php b/app/Commands/Stack/Compile.php index 0f97fb7..53f5148 100644 --- a/app/Commands/Stack/Compile.php +++ b/app/Commands/Stack/Compile.php @@ -40,7 +40,7 @@ class Compile extends Command $serializer = $this->getSerializer(); $unserializer = $this->getUnserializer(); $options = null; - $engine->setSerializer($serializer)->setUnserializer($unserializer)->setCompiler(new \App\Engine\Cfnpp($options = new \App\Engine\CfnppOptions())); + $engine->setSerializer($serializer)->setUnserializer($unserializer)->setCompiler(new \App\Engine\Cfnpp\Compiler($options = new \App\Engine\Cfnpp\Options())); $output = $engine->process($this->argument('in_file'), $options); diff --git a/app/Engine/Cfnpp.php b/app/Engine/Cfnpp/Compiler.php similarity index 94% rename from app/Engine/Cfnpp.php rename to app/Engine/Cfnpp/Compiler.php index 185a784..7920562 100644 --- a/app/Engine/Cfnpp.php +++ b/app/Engine/Cfnpp/Compiler.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Engine; +namespace App\Engine\Cfnpp; use App\Dom\Document; use App\Dom\Node; @@ -14,7 +14,7 @@ use App\Dom\NodeFunction; * * @author Adam Pippin */ -class Cfnpp implements ICompile +class Compiler implements \App\Engine\ICompile { /** * Functions that can be called by the document. @@ -67,14 +67,14 @@ class Cfnpp implements ICompile * Compile a set of documents and return the result. * * @param Document[] $documents - * @param IOptions $options + * @param \App\Engine\IOptions $options * @return void */ - public function compile(array $documents, IOptions $options): Document + public function compile(array $documents, \App\Engine\IOptions $options): Document { - if (!($options instanceof CfnppOptions)) + if (!($options instanceof Options)) { - throw new \Exception('Cfnpp compiler requires CfnppOptions'); + throw new \Exception('Cfnpp\Compiler requires Cfnpp\Options'); } // Initialize state @@ -83,7 +83,7 @@ class Cfnpp implements ICompile $this->merge_functions = []; // Register built-in functions - $cfnpp_functions = new CfnppFunctions($this, $options); + $cfnpp_functions = new Functions($this, $options); $cfnpp_functions->register($this); // Process each passed document diff --git a/app/Engine/CfnppFunctions.php b/app/Engine/Cfnpp/Functions.php similarity index 90% rename from app/Engine/CfnppFunctions.php rename to app/Engine/Cfnpp/Functions.php index f9bb6ec..0dca211 100644 --- a/app/Engine/CfnppFunctions.php +++ b/app/Engine/Cfnpp/Functions.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Engine; +namespace App\Engine\Cfnpp; use App\Dom\Node; use App\Dom\NodeValue; @@ -14,21 +14,21 @@ use App\Dom\NodeFunctionValue; * * @author Adam Pippin */ -class CfnppFunctions +class Functions { /** * cfnpp compiler. - * @var Cfnpp + * @var Compiler */ protected $compiler; /** * cfnpp compiler options, stores state. - * @var CfnppOptions + * @var Options */ protected $options; - public function __construct(Cfnpp $compiler, CfnppOptions $options) + public function __construct(Compiler $compiler, Options $options) { $this->compiler = $compiler; $this->options = $options; @@ -38,10 +38,10 @@ class CfnppFunctions * Examines this class with reflection and registers all functions on a cfnpp * compiler instance. * - * @param Cfnpp $compiler + * @param Compiler $compiler * @return void */ - public function register(Cfnpp $compiler): void + public function register(Compiler $compiler): void { $reflection = new \ReflectionClass(static::class); $methods = $reflection->getMethods(); diff --git a/app/Engine/CfnppOptions.php b/app/Engine/Cfnpp/Options.php similarity index 96% rename from app/Engine/CfnppOptions.php rename to app/Engine/Cfnpp/Options.php index ffc825e..584c7af 100644 --- a/app/Engine/CfnppOptions.php +++ b/app/Engine/Cfnpp/Options.php @@ -2,14 +2,16 @@ declare(strict_types=1); -namespace App\Engine; +namespace App\Engine\Cfnpp; + +use \App\Engine\IOptions; /** * Options for controlling the Cfnpp compilation process. * * @author Adam Pippin */ -class CfnppOptions implements IOptions +class Options implements \App\Engine\IOptions { /** * Store variables for use in templates.