예제 #1
0
 function testToBooleanException()
 {
     // invalid values
     $invalid = array(" true ", 2);
     foreach ($invalid as $val) {
         try {
             ObjectUtils::toBoolean(" true ");
             $this->fail("The value, \"{$val}\", should not have been able to be cast to a boolean");
         } catch (Exception $e) {
             // noop
         }
     }
 }
예제 #2
0
 /**
  * Get boolean value for key. This is the same as get() but attempts to
  * cast the value too boolean for convenience.
  *
  * @param string $key Key to message you're looking for.
  * @param boolean $default Default value if key was not found.
  *
  * @throws Exception if the property or default could not be cast to
  * boolean.
  */
 public function getBool($key, $default = NULL)
 {
     $value = self::get($key, $default, FALSE);
     try {
         return ObjectUtils::toBoolean($value);
     } catch (Exception $e) {
         throw new Exception("The property found, " . $value . ", with the key \"" . $key . "\" could not be converted to a boolean value in the file \"" . $this->file . "\".");
     }
 }