Hello there!
Given this ugly method:
public function convert_cell_value( $val, $type )
{
if($type == 'String')
{
return $val;
}
elseif($type == 'Number')
{
if($val - intval($val) > 0)
{
return $val;
}
else
{
return intval($val);
}
}
else
{
return $val;
}
}
Now my ten billion $ question is: when i should return values (not in this method but any other like this) to apply the DRY principles and go for performance too. Or: There's something wrong with my thought about performance and it's nothing to do with it when i return some value immediately?
Bonus question: Is there a simpler trick to get decimals than this?
if($val - intval($val) > 0)
{
return $val;
}
Thanks for your precious time, fabrik