本文整理匯總了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;
}