Allow setting percent for fare overrides against base fare #125
This commit is contained in:
32
app/Support/Math.php
Normal file
32
app/Support/Math.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
/**
|
||||
* Helper math
|
||||
* @package App\Support
|
||||
*/
|
||||
class Math
|
||||
{
|
||||
|
||||
/**
|
||||
* Add/subtract a percentage to a number
|
||||
* @param $number
|
||||
* @param $percent
|
||||
* @return float
|
||||
*/
|
||||
public static function addPercent($number, $percent): float
|
||||
{
|
||||
if(!is_numeric($number)) {
|
||||
$number = (float) $number;
|
||||
}
|
||||
|
||||
if(!is_numeric($percent)) {
|
||||
$percent = (float) $percent;
|
||||
}
|
||||
|
||||
|
||||
return $number + ($number * ($percent/100));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user