function __construct($c, $u) { if (!in_array($c, Currencies\codes())) { throw new InvalidArgumentException("'{$c}' is not a recognized currency-code"); } if (!is_numeric($u)) { throw new InvalidArgumentException("Second parameter must be valid numeric value"); } $this->currencyCode = $c; $this->numUnits = doubleval($u); }
function testCurrenciesRegistry() { assertTrue(in_array('USD', Currencies\codes())); assertTrue(in_array('EUR', Currencies\codes())); assertTrue(in_array('BTC', Currencies\codes())); }