Skip to content

Commit

Permalink
Fix: typo
Browse files Browse the repository at this point in the history
jordanbrauer committed Feb 4, 2018
1 parent aa836ec commit 7687d1a
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/UnitConverter/UnitConverter.php
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ protected function calculate (
throw new MissingCalculatorException("No calculator was found to perform mathematical operations with.");

# Attempt a self conversion if one exists (e.g., temperatures)
$selConversion = $from->convert($calculator, $value, $to, $precision);
$selfConversion = $from->convert($calculator, $value, $to, $precision);
if ($selfConversion) return $selfConversion;

$fromUnits = $from->getUnits();
@@ -262,4 +262,39 @@ protected function castUnitsTo (string $type): array

return $units;
}

/**
* Print debug output for the current calculation.
*
* @throws ErrorException If dev dependencies are missing.
* @return $this
*/
public function debug (): UnitConverterInterface
{
$dumper = "var_dump";
if (function_exists("dump")) $dumper = "dump";

# debug output
echo PHP_EOL;
echo "Debug out for caluclation:";
echo PHP_EOL;
echo "--------------------------";
echo PHP_EOL;
$dumper([
"precision" => null,
"rounding_mode" => null,
"units" => [
"value" => null,
"from" => null,
"to" => null,
],
"products" => [
"mul" => null,
"div" => null,
"result" => null,
],
]);

return $this;
}
}

0 comments on commit 7687d1a

Please sign in to comment.