I have taken over maintenance of some code, and have restructured it after reading some documents about PSR-2:
<?php
function calc_p()
{
list($arg1, $arg2, $arg3) = func_get_args();
switch($arg1) {
case 'ebook':
$bp = 5;
$tax = .08;
break;
case 'audio_book':
$bp = 5;
$tax = .08;
break;
case 'text_book':
$bp = 7.5;
$tax = .1;
break;
}
$bp = ($bp + ($bp*$tax));
//Calclate shipping
if($arg3 == 'California') {
}
else {
$bp = $bp + 1;
}
if ($arg3 == 'Texas') {
$norm = $bp;
$bp = $norm + 5;
}
//final price format: $XX:XX
$final_price = '$'.$bp;
if (strpos($final_price, '.')) {
$num = (2 - (strlen(substr($final_price, strpos($final_price, '.') + 1))));
for ($num>0; $num--;) {
$final_price .= '0';
}
}
elseif (strpos($final_price, '.') == FALSE) {
$final_price = $final_price .'.00';
}
else {
}
return $final_price;
}
$totalprice = calc_p('text_book','oldversion','Texas');
echo '<p style="font-weight: bold;">Total Price: </p>' . $totalprice;
?>
I wanted to ask if what I've done is already enough to follow the coding standards, or if I am missing something.