From 7c2ebba47bc9b20ac4a3ef6a2c445cd6adf545d1 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 15 Oct 2017 21:03:29 +0200 Subject: [PATCH] Fix after tests --- Utils/Converter/Measurement.php | 13 +++++++++++-- Utils/Converter/Numeric.php | 7 ++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Utils/Converter/Measurement.php b/Utils/Converter/Measurement.php index f9f2e3555..8975cf0b2 100644 --- a/Utils/Converter/Measurement.php +++ b/Utils/Converter/Measurement.php @@ -26,6 +26,15 @@ namespace phpOMS\Utils\Converter; */ class Measurement { + /** + * Constructor. + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + private function __construct() + { + } /** * Convert temperature. @@ -88,7 +97,7 @@ class Measurement $value = ($value - 273.15) * 1.5 - 100; break; case TemperatureType::NEWTON: - $value = ($value - 273.15) / 0.33; + $value = ($value - 273.15) * 0.33; break; case TemperatureType::ROMER: $value = ($value - 273.15) * 0.525 + 7.5; @@ -1221,7 +1230,7 @@ class Measurement * * @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) { case EnergyPowerType::JOULS: diff --git a/Utils/Converter/Numeric.php b/Utils/Converter/Numeric.php index e978da495..c77e628b0 100644 --- a/Utils/Converter/Numeric.php +++ b/Utils/Converter/Numeric.php @@ -39,6 +39,7 @@ class Numeric * Constructor. * * @since 1.0.0 + * @codeCoverageIgnore */ private function __construct() { @@ -73,7 +74,7 @@ class Numeric $newOutput = 0; 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; @@ -86,8 +87,8 @@ class Numeric } while ($base10 !== '0') { - $newOutput = $toBase[bcmod($base10, $toLen)] . $newOutput; - $base10 = bcdiv($base10, $toLen, 0); + $newOutput = $toBase[bcmod($base10, (string) $toLen)] . $newOutput; + $base10 = bcdiv($base10, (string) $toLen, 0); } return $newOutput;