public function testIntTypeConvertsValuesToInteger() { $t = new IntType(12); $this->assertInternalType('int', $t->get()); $this->assertEquals(12, $t->get()); $t = new IntType('foo'); $this->assertInternalType('int', $t->get()); $this->assertEquals(0, $t->get()); $t = new IntType('34'); $this->assertInternalType('int', $t->get()); $this->assertEquals(34, $t->get()); $t = new IntType('34.6'); $this->assertInternalType('int', $t->get()); $this->assertEquals(34, $t->get()); }
/** * Return currency amount formatted for display * * @return StringType */ public function display() { $formatter = new \NumberFormatter($this->locale->get(), \NumberFormatter::CURRENCY); $formatter->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $this->symbol->get()); $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision->get()); return new StringType(sprintf($this->displayFormat, $formatter->format($this->getAsFloat()))); }