function test_btc_commission($btc, $already_paid = '0') { $commission = commission_on_btc(numstr_to_internal($btc), numstr_to_internal($already_paid)); echo "<li>commission buying <b>{$btc}</b> BTC is <b>", internal_to_numstr($commission), "</b> " . CURRENCY; if ($already_paid) { echo " if {$already_paid} was already paid"; } echo "<br/>\n"; }
function commission_on_type($amount, $curr_type, $already_paid) { if ($curr_type == CURRENCY) { return commission_on_fiat($amount, $already_paid); } if ($curr_type == 'BTC') { return commission_on_btc($amount, $already_paid); } throw new Error('Unknown currency type', "Type {$curr_type} isn't " . CURRENCY . " or BTC"); }