/** * 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(); }
/** * @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()); }
/** * @ZF-9491 */ public function testCurrencyWithSelfPattern() { $currency = new Zend_Currency(array('value' => 10000, 'format' => '#,#0', 'locale' => 'de_DE')); $this->assertEquals('1.00.00', $currency->toString()); }
/** * testing toString * */ public function testToString() { $USD = new Zend_Currency('USD', 'en_US'); $this->assertSame($USD->toString(), 'US Dollar'); }
/** * 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(); }