Example #1
0
 /**
  * Validate that the provided value is a valid double.
  *
  * @since 1.0
  */
 public function testIsDouble()
 {
     $this->assertTrue(Validator::isDouble(10.0));
     $this->assertTrue(Validator::isDouble(-10.0));
     $this->assertTrue(Validator::isDouble(0.1));
     $this->assertFalse(Validator::isDouble('twenty'));
     $this->assertTrue(Validator::isDouble(100));
     $this->assertTrue(Validator::isDouble('100'));
 }
Example #2
0
 /**
  * Setter for the Double value.
  *
  * @param float $val
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\IllegalArguementException
  */
 public function setValue($val)
 {
     if (!Validator::isDouble($val)) {
         throw new IllegalArguementException($this->helper);
     }
     if (mb_strlen($val) <= $this->size) {
         $this->value = $val;
     } else {
         throw new IllegalArguementException($this->helper);
     }
 }