Here is my code:
if ( $identity == "asker" ) {
$min_amount = 3000;
} elseif ( $identity == "supporter" ) {
$min_amount = 5000;
} elseif( $identity == "viewer" ) {
$min_amount = 7000;
} else {
throw new Exception('something went wrong');
}
$check_credit = $bounty->check_credit($min_amount);
if ($check_credit["status"] == 1) {
if ( $identity == "asker" ) {
$make_bounty_system["content"] = $bounty->make_devote_html($check_credit["amount"], $identity);
} elseif ( $identity == "supporter" ) {
$make_bounty_system["content"] = $bounty->make_devote_html($check_credit["amount"], $identity);
} elseif( $identity == "viewer" ) {
$make_bounty_system["content"] = $bounty->make_devote_html($check_credit["amount"], $identity);
} else {
throw new Exception('something went wrong');
}
}
As you can see, the same logic ($identity == ?
) is repeated twice. Any idea how can I write the same code cleaner?