本文整理汇总了PHP中Zend_Measure_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Measure_Abstract类的具体用法?PHP Zend_Measure_Abstract怎么用?PHP Zend_Measure_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Measure_Abstract类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compare
/**
* Compares two units
*
* @param Zend_Measure_Abstract $object object of same unit type
* @return boolean
*/
public function compare($object)
{
$object->setType($this->getType());
$value = $this->getValue(-1) - $object->getValue(-1);
if ($value < 0) {
return -1;
} else {
if ($value > 0) {
return 1;
}
}
return 0;
}
示例2: filter
/**
* Defined by Zend_Filter_Interface
*
* Returns the numerical value, from measure string
*
* @param string $value
* @return integer|string
*/
public function filter($value)
{
$locale = $this->_measure->getLocale();
$matched = false;
foreach ($this->_measure->getConversionList() as $key => $conversion) {
if (preg_match("~^(.*)" . $conversion[1] . "\$~", $value, $matches)) {
try {
// $number = Zend_Locale_Format::getNumber(trim($matches[1]), array('locale' => $locale));
$this->_measure->setType($key)->setValue(trim($matches[1]));
} catch (Exception $e) {
continue;
}
$matched = true;
}
}
return $matched ? $this->_measure->getValue() : $value;
}
示例3: toString
/**
* Returns a string representation
*
* @return string
*/
public function toString()
{
return parent::getValue() . ' ' . self::$_UNITS[parent::getType()][1];
}
示例4: toString
/**
* Returns a string representation
*
* @return string
*/
public function toString()
{
return parent::getValue();
}