Name; } /** * @param mixed $variable * @throws InstructionException * @noinspection PhpMissingParamTypeInspection */ public function setName($variable): void { $this->Name = InstructionBuilder::fromRaw($variable); } /** * @return mixed */ public function getValue(): mixed { return $this->Value; } /** * @param mixed $value * @throws InstructionException * @noinspection PhpMissingParamTypeInspection */ public function setValue($value): void { $this->Value = InstructionBuilder::fromRaw($value); } /** * Returns an array representation of the object * * @return array */ public function toArray(): array { return InstructionBuilder::toRaw(self::getType(), [ 'name' => $this->Name, 'value' => $this->Value ]); } /** * @param array $data * @return InstructionInterface * @throws InstructionException */ public static function fromArray(array $data): InstructionInterface { $instruction = new self(); $instruction->setName($data['name'] ?? null); $instruction->setValue($data['value'] ?? null); return $instruction; } /** * @param Engine $engine * @return void * @throws EvaluationException * @throws TypeException */ public function eval(Engine $engine): void { $name = $engine->eval($this->Name); $value = $engine->eval($this->Value); if(!is_string($name)) throw new TypeException(sprintf('Variable name must be a string, %s given', Utilities::getType($name, true))); $engine->getEnvironment()->setRuntimeVariable($name, $value); } /** * @inheritDoc */ public function __toString(): string { return sprintf( self::getType() . ' %s VALUE %s', Utilities::entityToString($this->Name), Utilities::entityToString($this->Value) ); } }