本文整理汇总了PHP中LoggerOptionConverter::substConstants方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerOptionConverter::substConstants方法的具体用法?PHP LoggerOptionConverter::substConstants怎么用?PHP LoggerOptionConverter::substConstants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerOptionConverter
的用法示例。
在下文中一共展示了LoggerOptionConverter::substConstants方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setString
/**
* Setter function for string type.
*/
protected function setString($property, $value, $nullable = false)
{
if ($value === null) {
if ($nullable) {
$this->{$property} = null;
} else {
$this->warn("Null value given for '{$property}' property. Expected a string. Property not changed.");
}
} else {
try {
$value = LoggerOptionConverter::toStringEx($value);
$this->{$property} = LoggerOptionConverter::substConstants($value);
} catch (Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '{$property}' property: [{$value}]. Expected a string. Property not changed.");
}
}
}
示例2: testSubstituteConstants
public function testSubstituteConstants()
{
define('OTHER_CONSTANT', 'OTHER');
define('MY_CONSTANT', 'TEST');
define('NEXT_CONSTANT', 'NEXT');
$result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT}.');
self::assertEquals('Value of key is TEST.', $result);
$result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT} or ${OTHER_CONSTANT}.');
self::assertEquals('Value of key is TEST or OTHER.', $result);
$result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT_CONSTANT}.');
self::assertEquals('Value of key is DEFINE.', $result);
$result = LoggerOptionConverter::substConstants('Value of key is ${MY_CONSTANT_CONSTANT} or ${MY_CONSTANT_CONSTANT_OTHER}.');
self::assertEquals('Value of key is DEFINE or DEFINE_OTHER.', $result);
}