Prado\TPropertyValue::ensureBoolean PHP Метод

ensureBoolean() публичный статический Метод

Note, string 'true' (case-insensitive) will be converted to true, string 'false' (case-insensitive) will be converted to false. If a string represents a non-zero number, it will be treated as true.
public static ensureBoolean ( $value ) : boolean
Результат boolean
    public static function ensureBoolean($value)
    {
        if (is_string($value)) {
            return strcasecmp($value, 'true') == 0 || $value != 0;
        } else {
            return (bool) $value;
        }
    }

Usage Example

Пример #1
0
 /**
  * Initialize the TTranslate translation components
  */
 public static function init($catalogue = 'messages')
 {
     static $saveEventHandlerAttached = false;
     //initialized the default class wide formatter
     if (!isset(self::$formatters[$catalogue])) {
         $app = Prado::getApplication()->getGlobalization();
         $config = $app->getTranslationConfiguration();
         $source = MessageSource::factory($config['type'], $config['source'], $config['filename']);
         $source->setCulture($app->getCulture());
         if (isset($config['cache'])) {
             $source->setCache(new MessageCache($config['cache']));
         }
         self::$formatters[$catalogue] = new MessageFormat($source, $app->getCharset());
         //mark untranslated text
         if ($ps = $config['marker']) {
             self::$formatters[$catalogue]->setUntranslatedPS(array($ps, $ps));
         }
         //save the message on end request
         // Do it only once !
         if (!$saveEventHandlerAttached && TPropertyValue::ensureBoolean($config['autosave'])) {
             Prado::getApplication()->attachEventHandler('OnEndRequest', array('Translation', 'saveMessages'));
             $saveEventHandlerAttached = true;
         }
     }
 }
All Usage Examples Of Prado\TPropertyValue::ensureBoolean