/** * @test */ public function testCanToggleSymbolPosition() { $this->currency->load('USD'); $this->assertTrue($this->currency->isSymbolFirst()); $this->assertEquals('$ 100.00', $this->currency->format(100, true)); $this->assertFalse($this->currency->setSymbolLast()->isSymbolFirst()); $this->assertEquals('100.00 $', $this->currency->format(100, true)); }
/** * @param float|int $amount * * @param bool $format * * @throws InvalidTypeException * @throws \Exception * * @return float */ public function calculate($amount = 1, $format = false) { $this->checkAmount($amount); $amount = round($this->exchangeRate * $amount, 2, PHP_ROUND_HALF_UP); if ($format) { return $this->to->format($amount, true); } return $amount; }