src/Compiler/Command/Define/DefineObjectTypeDefinitionCommand.php
<?php
declare(strict_types=1);
namespace Railt\SDL\Compiler\Command\Define;
use Railt\SDL\Compiler\Command\Build\BuildObjectTypeDefinitionCommand;
use Railt\SDL\Compiler\Command\DefineCommand;
use Railt\SDL\Node\Statement\Definition\ObjectTypeDefinitionNode;
use Railt\TypeSystem\Definition\Type\ObjectType;
/**
* @template-extends DefineCommand<ObjectTypeDefinitionNode>
*
* @internal This is an internal library class, please do not use it in your code.
* @psalm-internal Railt\SDL\Compiler\Command
*/
final class DefineObjectTypeDefinitionCommand extends DefineCommand
{
public function exec(): void
{
$type = new ObjectType($this->stmt->name->value);
if ($this->stmt->description->value !== null) {
$type->setDescription($this->stmt->description->value->value);
}
$this->ctx->addType($type, $this->stmt->name);
$this->ctx->push(new BuildObjectTypeDefinitionCommand(
ctx: $this->ctx,
node: $this->stmt,
definition: $type,
));
}
}