Refactored \RTEX\Objects\Program\Instructions > Equals > eval()
This commit is contained in:
parent
cfb55fd7df
commit
172bc4866a
1 changed files with 11 additions and 12 deletions
|
@ -8,8 +8,8 @@
|
|||
use RTEX\Classes\InstructionBuilder;
|
||||
use RTEX\Classes\Utilities;
|
||||
use RTEX\Engine;
|
||||
use RTEX\Exceptions\Core\MalformedInstructionException;
|
||||
use RTEX\Exceptions\Core\UnsupportedVariableType;
|
||||
use RTEX\Exceptions\EvaluationException;
|
||||
use RTEX\Exceptions\InstructionException;
|
||||
use RTEX\Interfaces\InstructionInterface;
|
||||
|
||||
class Equals implements InstructionInterface
|
||||
|
@ -38,7 +38,6 @@
|
|||
* Returns an array representation of the instruction
|
||||
*
|
||||
* @return array
|
||||
* @throws UnsupportedVariableType
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
@ -53,8 +52,7 @@
|
|||
*
|
||||
* @param array $data
|
||||
* @return InstructionInterface
|
||||
* @throws MalformedInstructionException
|
||||
* @throws UnsupportedVariableType
|
||||
* @throws InstructionException
|
||||
*/
|
||||
public static function fromArray(array $data): InstructionInterface
|
||||
{
|
||||
|
@ -67,18 +65,21 @@
|
|||
/**
|
||||
* @param Engine $engine
|
||||
* @return bool
|
||||
* @throws UnsupportedVariableType
|
||||
* @throws EvaluationException
|
||||
* @throws EvaluationException
|
||||
*/
|
||||
public function eval(Engine $engine): bool
|
||||
{
|
||||
return (intval($engine->eval($this->A)) == intval($engine->eval($this->B)));
|
||||
$a = $engine->eval($this->A);
|
||||
$b = $engine->eval($this->B);
|
||||
|
||||
return $a === $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of the instruction
|
||||
*
|
||||
* @return string
|
||||
* @throws UnsupportedVariableType
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
|
@ -103,8 +104,7 @@
|
|||
* Sets the value of A
|
||||
*
|
||||
* @param mixed $A
|
||||
* @throws UnsupportedVariableType
|
||||
* @throws MalformedInstructionException
|
||||
* @throws InstructionException
|
||||
*/
|
||||
public function setA(mixed $A): void
|
||||
{
|
||||
|
@ -125,8 +125,7 @@
|
|||
* Sets the value of B
|
||||
*
|
||||
* @param mixed $B
|
||||
* @throws MalformedInstructionException
|
||||
* @throws UnsupportedVariableType
|
||||
* @throws InstructionException
|
||||
*/
|
||||
public function setB(mixed $B): void
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue