public function testShouldTakeIntegerForConversion()
 {
     $mockedService = new Service();
     $mockedService->setExchangeRates(['USD' => 1.13, 'EUR' => 1]);
     $converter = new Converter($mockedService);
     $actual = $converter->convert(1, 'USD', 'EUR');
     $expected = 1.13;
     $this->assertEquals($expected, $actual);
 }
Beispiel #2
0
 /**
  * @param string $amount
  * @return array
  */
 public function parse($amount)
 {
     $currency = $value = null;
     $symbols = $this->service->getSymbols();
     if (!empty($symbols)) {
         $values = array_flip($symbols);
         foreach ($values as $char => $currency) {
             if (false !== strstr($amount, $char)) {
                 break;
             }
         }
         $value = floatval(strtr($amount, [$char => '']));
     }
     return [$value, $currency];
 }