本文整理汇总了PHP中Value::fromString方法的典型用法代码示例。如果您正苦于以下问题:PHP Value::fromString方法的具体用法?PHP Value::fromString怎么用?PHP Value::fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Value
的用法示例。
在下文中一共展示了Value::fromString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
function parse($value)
{
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return Value::fromString($value);
}
示例2: parse
function parse($value)
{
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$value = trim(strtolower($value));
switch (strtolower($value)) {
case "xx-small":
return Value::fromData(BASE_FONT_SIZE_PT * 3 / 5, UNIT_PT);
case "x-small":
return Value::fromData(BASE_FONT_SIZE_PT * 3 / 4, UNIT_PT);
case "small":
return Value::fromData(BASE_FONT_SIZE_PT * 8 / 9, UNIT_PT);
case "medium":
return Value::fromData(BASE_FONT_SIZE_PT, UNIT_PT);
case "large":
return Value::fromData(BASE_FONT_SIZE_PT * 6 / 5, UNIT_PT);
case "x-large":
return Value::fromData(BASE_FONT_SIZE_PT * 3 / 2, UNIT_PT);
case "xx-large":
return Value::fromData(BASE_FONT_SIZE_PT * 2 / 1, UNIT_PT);
}
switch (strtolower($value)) {
case "larger":
return Value::fromData(1.2, UNIT_EM);
case "smaller":
return Value::fromData(0.83, UNIT_EM);
// 0.83 = 1/1.2
}
if (preg_match("/(\\d+\\.?\\d*)%/i", $value, $matches)) {
return Value::fromData($matches[1] / 100, UNIT_EM);
}
return Value::fromString($value);
}
示例3: parse
function parse($value)
{
$value = trim($value);
if ($value === 'inherit') {
return CSS_PROPERTY_INHERIT;
}
if ($value === 'normal') {
return $this->_default_value;
}
return Value::fromString($value);
}
示例4: parse_value
function parse_value($value)
{
switch (strtolower($value)) {
case 'thin':
return Value::fromString('1px');
case 'medium':
return Value::fromString('3px');
case 'thick':
return Value::fromString('5px');
default:
return Value::fromString($value);
}
}
示例5: init
function init($data)
{
$len = strlen($data);
$is_percentage = false;
if ($len > 0) {
$is_percentage = $data[$len - 1] === '%';
}
$value = new MarginSideValue();
$value->_units = Value::fromString($data);
$value->value = $data;
$value->percentage = $is_percentage ? (int) $data : null;
$value->auto = $data === 'auto';
return $value;
}
示例6: strlen
function &_fromString($value, &$class_object)
{
if ($value == 'inherit') {
$dummy = CSS_PROPERTY_INHERIT;
return $dummy;
}
if ($value == 'auto' || $value == '') {
$class_object->init(null, VALUE_AUTO);
return $class_object;
}
$strlen = strlen($value);
if ($value[$strlen - 1] == '%') {
$class_object->init((double) $value, VALUE_PERCENTAGE);
return $class_object;
}
$class_object->init(Value::fromString($value), VALUE_NORMAL);
return $class_object;
}
示例7: CSSBorder
function CSSBorder()
{
$this->CSSPropertyHandler(false, false);
$this->_defaultValue = BorderPDF::create(array('top' => array('width' => Value::fromString('2px'), 'color' => array(0, 0, 0), 'style' => BS_NONE), 'right' => array('width' => Value::fromString('2px'), 'color' => array(0, 0, 0), 'style' => BS_NONE), 'bottom' => array('width' => Value::fromString('2px'), 'color' => array(0, 0, 0), 'style' => BS_NONE), 'left' => array('width' => Value::fromString('2px'), 'color' => array(0, 0, 0), 'style' => BS_NONE)));
}
示例8: parse
function parse($value)
{
return Value::fromString($value);
}