예제 #1
0
 public function __construct($symbol = null)
 {
     $this->symbol = $symbol;
     $this->environment = Environment::getInstance();
     $this->traversable = null;
     $this->forAll = null;
 }
예제 #2
0
 public function m($symbolOne, $symbolTwo)
 {
     $operandOne = Environment::getInstance()->resolve($symbolOne);
     if (is_int($symbolTwo) || is_float($symbolTwo)) {
         $operandTwo = $symbolTwo;
     } else {
         $operandTwo = Environment::getInstance()->resolve($symbolTwo);
     }
     // Make sure operandOne is an int or a float
     if (!is_int($operandOne) && !is_float($operandOne)) {
         throw new \InvalidArgumentException("The value for symbol '{$symbolOne}' is neither an int nor a float.");
     }
     // Make sure operandTwo is an int or a float
     if (!is_int($operandTwo) && !is_float($operandTwo)) {
         throw new \InvalidArgumentException("The value for symbol '{$symbolTwo}' is neither an int nor a float.");
     }
     $result = $operandOne - $operandTwo;
     $this->setOperand("__x__", $result);
 }
예제 #3
0
 /**
  * Test the getInstance method
  *
  * This method must return the same instance of the Environment class
  */
 public function testGetInstance()
 {
     $environmentTwo = Environment::getInstance();
     $this->assertSame($this->environment, $environmentTwo, "Failed to assert that the getInstance method returns the same environment. The environment must be a singleton.");
 }
예제 #4
0
파일: Let.php 프로젝트: ntwalibas/contracts
 public function be($value)
 {
     Environment::getInstance()->attach($this->symbol, $value);
 }