本文整理汇总了PHP中LoggerOptionConverter::toBooleanEx方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerOptionConverter::toBooleanEx方法的具体用法?PHP LoggerOptionConverter::toBooleanEx怎么用?PHP LoggerOptionConverter::toBooleanEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerOptionConverter
的用法示例。
在下文中一共展示了LoggerOptionConverter::toBooleanEx方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setBoolean
/**
* Setter function for boolean type.
*/
protected function setBoolean($property, $value)
{
try {
$this->{$property} = LoggerOptionConverter::toBooleanEx($value);
} catch (Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '{$property}' property: [{$value}]. Expected a boolean value. Property not changed.");
}
}
示例2: configureLogger
/**
* Configures a logger.
*
* @param Logger $logger The logger to configure
* @param array $config Logger configuration options.
*/
private function configureLogger(Logger $logger, $config)
{
$loggerName = $logger->getName();
// Set logger level
if (isset($config['level'])) {
$level = LoggerLevel::toLevel($config['level']);
if (isset($level)) {
$logger->setLevel($level);
} else {
$this->warn("Invalid level value [{$config['level']}] specified for logger [{$loggerName}]. Ignoring level definition.");
}
}
// Link appenders to logger
if (isset($config['appenders'])) {
foreach ($config['appenders'] as $appenderName) {
if (isset($this->appenders[$appenderName])) {
$logger->addAppender($this->appenders[$appenderName]);
} else {
$this->warn("Nonexistnant appender [{$appenderName}] linked to logger [{$loggerName}].");
}
}
}
// Set logger additivity
if (isset($config['additivity'])) {
try {
$additivity = LoggerOptionConverter::toBooleanEx($config['additivity'], null);
$logger->setAdditivity($additivity);
} catch (Exception $ex) {
$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [{$loggerName}]. Ignoring additivity setting.");
}
}
}
示例3: testBooleanValues
/**
* Check that various boolean equivalents from ini file convert properly
* to boolean.
*/
public function testBooleanValues()
{
$values = parse_ini_file(PHPUNIT_CONFIG_DIR . '/adapters/ini/values.ini');
$actual = LoggerOptionConverter::toBooleanEx($values['unquoted_true']);
self::assertTrue($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['unquoted_yes']);
self::assertTrue($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['unquoted_false']);
self::assertFalse($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['unquoted_no']);
self::assertFalse($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['quoted_true']);
self::assertTrue($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['quoted_false']);
self::assertFalse($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['unquoted_one']);
self::assertTrue($actual);
$actual = LoggerOptionConverter::toBooleanEx($values['unquoted_zero']);
self::assertFalse($actual);
}
示例4: testToBooleanFailure2
/**
* Test fail on invalid string.
* @expectedException LoggerException
* @expectedExceptionMessage Given value ['foo'] cannot be converted to boolean.
*/
public function testToBooleanFailure2()
{
LoggerOptionConverter::toBooleanEx('foo');
}