Fix after tests

This commit is contained in:
Dennis Eichhorn 2017-10-15 21:03:29 +02:00
parent 56b0a40c81
commit 7c2ebba47b
2 changed files with 15 additions and 5 deletions

View File

@ -26,6 +26,15 @@ namespace phpOMS\Utils\Converter;
*/ */
class Measurement class Measurement
{ {
/**
* Constructor.
*
* @since 1.0.0
* @codeCoverageIgnore
*/
private function __construct()
{
}
/** /**
* Convert temperature. * Convert temperature.
@ -88,7 +97,7 @@ class Measurement
$value = ($value - 273.15) * 1.5 - 100; $value = ($value - 273.15) * 1.5 - 100;
break; break;
case TemperatureType::NEWTON: case TemperatureType::NEWTON:
$value = ($value - 273.15) / 0.33; $value = ($value - 273.15) * 0.33;
break; break;
case TemperatureType::ROMER: case TemperatureType::ROMER:
$value = ($value - 273.15) * 0.525 + 7.5; $value = ($value - 273.15) * 0.525 + 7.5;
@ -1221,7 +1230,7 @@ class Measurement
* *
* @since 1.0.0 * @since 1.0.0
*/ */
public static function convertEnergie(float $value, string $from = EnergyPowerType::JOULS, string $to = EnergyPowerType::KILOWATT_HOUERS) : float public static function convertEnergy(float $value, string $from = EnergyPowerType::JOULS, string $to = EnergyPowerType::KILOWATT_HOUERS) : float
{ {
switch ($from) { switch ($from) {
case EnergyPowerType::JOULS: case EnergyPowerType::JOULS:

View File

@ -39,6 +39,7 @@ class Numeric
* Constructor. * Constructor.
* *
* @since 1.0.0 * @since 1.0.0
* @codeCoverageIgnore
*/ */
private function __construct() private function __construct()
{ {
@ -73,7 +74,7 @@ class Numeric
$newOutput = 0; $newOutput = 0;
for ($i = 1; $i <= $numberLen; $i++) { for ($i = 1; $i <= $numberLen; $i++) {
$newOutput = bcadd($newOutput, bcmul(array_search($number[$i - 1], $fromBase), bcpow($fromLen, $numberLen - $i))); $newOutput = bcadd((string) $newOutput, bcmul((string) array_search($number[$i - 1], $fromBase), bcpow((string) $fromLen, (string) ($numberLen - $i))));
} }
return $newOutput; return $newOutput;
@ -86,8 +87,8 @@ class Numeric
} }
while ($base10 !== '0') { while ($base10 !== '0') {
$newOutput = $toBase[bcmod($base10, $toLen)] . $newOutput; $newOutput = $toBase[bcmod($base10, (string) $toLen)] . $newOutput;
$base10 = bcdiv($base10, $toLen, 0); $base10 = bcdiv($base10, (string) $toLen, 0);
} }
return $newOutput; return $newOutput;