本文整理汇总了PHP中ezcConsoleOutput::isValidFormatCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcConsoleOutput::isValidFormatCode方法的具体用法?PHP ezcConsoleOutput::isValidFormatCode怎么用?PHP ezcConsoleOutput::isValidFormatCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcConsoleOutput
的用法示例。
在下文中一共展示了ezcConsoleOutput::isValidFormatCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormatCode
/**
* Returns the code for a given formating option of a given type.
*
* $type is the type of formating ('color', 'bgcolor' or 'style'), $key the
* name of the format to lookup. Returns the numeric code for the requested
* format or 0 if format or type do not exist.
*
* @see ezcConsoleOutput::isValidFormatCode()
*
* @param string $type Formatting type.
* @param string $key Format option name.
* @return int The code representation.
*/
protected function getFormatCode($type, $key)
{
if (!ezcConsoleOutput::isValidFormatCode($type, $key)) {
return 0;
}
return ezcConsoleOutput::${$type}[$key];
}
示例2: array
<?php
class ezcConsoleOutput
{
protected static $color = array('gray' => 30);
public static function isValidFormatCode($type, $key)
{
return isset(self::${$type}[$key]);
}
}
var_dump(ezcConsoleOutput::isValidFormatCode('color', 'gray'));
示例3: __set
/**
* Overloaded __set() method to gain read-only access to properties.
* It also performs checks on setting others.
*
* @throws ezcBasePropertyNotFoundException
* If the setting you try to access does not exists
* @throws ezcBaseValueException
* If trying to set an invalid value for a setting.
*
* @param string $propertyName Name of the attrinbute to access.
* @param string $val The value to set.
* @ignore
*/
public function __set($propertyName, $val)
{
if (!isset($this->properties[$propertyName])) {
throw new ezcBasePropertyNotFoundException($propertyName);
}
// Extry handling of multi styles
if ($propertyName === 'style') {
if (!is_array($val)) {
$val = array($val);
}
foreach ($val as $style) {
if (!ezcConsoleOutput::isValidFormatCode($propertyName, $style)) {
throw new ezcBaseValueException($propertyName, $style, 'valid ezcConsoleOutput format code');
}
}
$this->properties['style'] = $val;
return;
}
// Continue normal handling
if (($propertyName === "color" || $propertyName === "bgcolor") && !ezcConsoleOutput::isValidFormatCode($propertyName, $val)) {
throw new ezcBaseValueException($propertyName, $val, 'valid ezcConsoleOutput format code');
}
$this->properties[$propertyName] = $val;
}