示例#1
0
 /**
  * Format a numeric currency value and return it as a string
  *
  * @param int|float $value   any value that return true with is_numeric
  * @param array     $options additional options to pass to the currency
  *                           constructor
  * @param string    $locale  locale value
  *
  * @throws InvalidParameterException if the $value parameter is not numeric
  * @return string the formatted value
  */
 public function currency($value, $options = array(), $locale = null)
 {
     if (!is_numeric($value)) {
         throw new InvalidArgumentException('Numeric argument expected ' . gettype($value) . ' given');
     }
     $options = array_merge($options, array('value' => $value));
     $currency = new Zend_Currency($options, $locale);
     return $currency->toString();
 }
示例#2
0
 /**
  * @group ZF-11798
  * @dataProvider providerConstructorAllowsOverridingCurrencyDisplayFormat
  */
 public function testConstructorAllowsOverridingCurrencyDisplayFormat($display, $expected)
 {
     $currency = new Zend_Currency(array('value' => 100, 'display' => $display), 'en_US');
     $this->assertEquals($expected, $currency->toString());
 }
示例#3
0
 /**
  * @ZF-9491
  */
 public function testCurrencyWithSelfPattern()
 {
     $currency = new Zend_Currency(array('value' => 10000, 'format' => '#,#0', 'locale' => 'de_DE'));
     $this->assertEquals('1.00.00', $currency->toString());
 }
示例#4
0
 /**
  * testing toString
  *
  */
 public function testToString()
 {
     $USD = new Zend_Currency('USD', 'en_US');
     $this->assertSame($USD->toString(), 'US Dollar');
 }
示例#5
0
 /**
  * IsLess values
  */
 public function testContructingPrecisionValues()
 {
     $currency = new Zend_Currency(array('value' => 100.5));
     $this->assertEquals('€ 100,50', $currency->toString('de_AT'));
 }
 /**
  * Get zend price
  */
 public function getZendPrice()
 {
     $zc = new Zend_Currency(array('value' => $this->_get('price')), strtoupper(Model_Lang::getCurrent()));
     return $zc->toString();
 }