Moved the bcmath wrapper method to the helper class for all over use

This commit is contained in:
2018-08-30 23:22:48 +02:00
parent b3c4414320
commit f3539185ab
7 changed files with 111 additions and 49 deletions

View File

@ -6158,46 +6158,4 @@ class Get
return false;
}
/**
* bc math wrapper (very basic not for accounting)
*
* @param string $type The type bc math
* @param int $val1 The first value
* @param int $val2 The second value
*
* @return int
*
*/
public function bcmath($type, $val1, $val2)
{
// build function name
$function = 'bc' . $type;
// use the bcmath function of available
if (function_exists($function))
{
return $function($val1, $val2);
}
// if function does not exist we use +-*/ operators (since it realy not that serious)
switch ($type)
{
// Multiply two numbers
case 'mul':
return round($val1 * $val2);
break;
// Divide of two numbers
case 'div':
return round($val1 / $val2);
break;
// Adding two numbers
case 'add':
return round($val1 + $val2);
break;
// Subtract one number from the other
case 'sub':
return round($val1 - $val2);
break;
}
return false;
}
}

View File

@ -1122,8 +1122,8 @@ class Infusion extends Interpretation
if ($this->langTag !== $tag)
{
$langStringNr = count($languageStrings);
$langStringSum = $this->bcmath('mul', $langStringNr, 100);
$percentage = $this->bcmath('div', $langStringSum, $mainLangLoader[$area]);
$langStringSum = ComponentbuilderHelper::bcmath('mul', $langStringNr, 100);
$percentage = ComponentbuilderHelper::bcmath('div', $langStringSum, $mainLangLoader[$area]);
$stringNAme = ($langStringNr == 1) ? '(string ' . $tag . ' translated)' : '(strings ' . $tag . ' translated)';
// force load if debug lines are added
if (!$this->debugLinenr)