本文整理汇总了PHP中Formatter::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Formatter::getInstance方法的具体用法?PHP Formatter::getInstance怎么用?PHP Formatter::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formatter
的用法示例。
在下文中一共展示了Formatter::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetInstance
/**
* @covers Formatter::getInstance
* @covers Formatter::Formatter
*/
public function testGetInstance()
{
$format = \Formatter::getInstance();
$this->assertEquals($this->formatter, $format);
}
示例2: convert
/**
* Get the unit from the form. If it's defined and different than the
* display unit, convert the value and set it back into this control's value.
* Then, format with proper number of digits.
*
* Do not call this method more than once!
*/
protected function convert()
{
$user = Transaction::getInstance()->getUser();
if ($this->getValue() !== null && Zend_Locale_Format::isNumber($this->getValue(), array("locale" => $user->getLocale()))) {
$form = $this->getForm();
// Get the 'hidden' value, which indicates the unit of the current value.
$unit = $form->getValue($this->getUnitFieldName());
// If the unit is different, convert
if ($unit && $unit != $this->displayUnit) {
$measure = MeasureUtils::newMeasure($unit, $this->getValue(), $user->getLocale());
$unitInfo = MeasureUtils::getUnitInfo($this->displayUnit);
$measure->setType($unitInfo['constantName']);
// Sets the new value without rounding and without formatting
$this->setValue($measure->getValue(-1, $user->getLocale()));
}
$format = Formatter::getInstance();
// Format and round the value
$this->setValue($format->number($format->getNumber($this->getValue()), $this->decimalDigits));
}
}
示例3: getFormatter
/**
* @return Formatter
*/
public function getFormatter()
{
return Formatter::getInstance();
}