Ejemplo n.º 1
0
 /**
  * @param string $key
  * @param float  $exchangeRate
  *
  * @return RateCollection
  */
 public function add($key, $exchangeRate)
 {
     $rate = new Rate();
     $rate->setKey($key)->setExchangeRate($exchangeRate);
     if (!$this->has($key)) {
         $this->put($key, $rate);
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function testCanCalculateAndFormatCurrency()
 {
     $this->rate->setIsoFrom('USD');
     $this->rate->setIsoTo('EUR');
     $this->rate->setExchangeRate(0.8051);
     $this->assertEquals('0.81', $this->rate->calculate());
     $this->assertEquals('241.53', $this->rate->calculate(300));
     $this->assertEquals('€ 0,81', $this->rate->calculate(1, true));
     $this->assertEquals('€ 805,09', $this->rate->calculate(999.99, true));
 }