Example #1
0
 /**
  * Validate that the provided value is a valid boolean.
  *
  * @since 1.0
  */
 public function testIsBoolean()
 {
     $this->assertTrue(Validator::isBoolean(true));
     $this->assertTrue(Validator::isBoolean(1));
     $this->assertTrue(Validator::isBoolean(0));
     $this->assertFalse(Validator::isBoolean('test'), 'test');
     $this->assertFalse(Validator::isBoolean(5));
     $this->assertFalse(Validator::isBoolean(1.0));
 }
Example #2
0
 /**
  * Used to set the Boolean value.
  *
  * @param mixed $val Will accept a boolean true/false or integer 1/0.
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\IllegalArguementException
  */
 public function setValue($val)
 {
     if (!Validator::isBoolean($val)) {
         throw new IllegalArguementException($this->helper);
     }
     if (Validator::isBooleanTrue($val)) {
         $this->value = 1;
         $this->booleanValue = true;
     } else {
         $this->value = 0;
         $this->booleanValue = false;
     }
 }