/**
  * @covers ::newFromVar
  */
 public function test_can_create_from_PHP_variable()
 {
     // ----------------------------------------------------------------
     // setup your test
     $value = 100;
     $reason = "must be > 100";
     // ----------------------------------------------------------------
     // perform the change
     $unit = ContractFailed::newFromVar($value, '$value', ['reason' => $reason]);
     // ----------------------------------------------------------------
     // test the results
     $this->assertInstanceOf(ContractFailed::class, $unit);
 }
 /**
  * check that an expression is true ... and if it is not, throw an
  * exception
  *
  * @param  mixed $data
  *         the value check we are checking
  * @param  string $fieldOrVarName
  *         the name of the field we are checking
  * @return boolean
  *         TRUE on success
  */
 public function to($data, $fieldOrVarName = 'value')
 {
     if ($this->expr === true) {
         return true;
     }
     // if we get here, then this assertion has failed
     throw ContractFailed::newFromVar($data, $fieldOrVarName, ['reason' => $this->reason]);
 }