schneespur/vendor/brick/math/phpunit.php
Michael 2c63440ed8 Revert: move code back to project root from schneespur/ subdirectory
- Reverts the schneespur/ subdirectory restructure (b8e426b)
- Restores package.json and vite.config.js (needed for npm build, were
  removed in an earlier cleanup before the restructure)
- Updates public/build/ assets with current Vite output (new content hashes)
2026-05-17 18:24:26 +00:00

52 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use Brick\Math\Internal\Calculator;
use Brick\Math\Internal\CalculatorRegistry;
require __DIR__ . '/vendor/autoload.php';
function getCalculatorImplementation(): Calculator
{
switch ($calculator = getenv('CALCULATOR')) {
case 'GMP':
$calculator = new Calculator\GmpCalculator();
break;
case 'BCMath':
$calculator = new Calculator\BcMathCalculator();
break;
case 'Native':
$calculator = new Calculator\NativeCalculator();
break;
default:
if ($calculator === false) {
echo 'CALCULATOR environment variable not set!' . PHP_EOL;
} else {
echo 'Unknown calculator: ' . $calculator . PHP_EOL;
}
echo 'Example usage: CALCULATOR={calculator} vendor/bin/phpunit' . PHP_EOL;
echo 'Available calculators: GMP, BCMath, Native' . PHP_EOL;
exit(1);
}
echo 'Using ', get_class($calculator), PHP_EOL;
return $calculator;
}
CalculatorRegistry::set(getCalculatorImplementation());
$scale = getenv('BCMATH_DEFAULT_SCALE');
if ($scale !== false) {
echo "Using bcscale($scale)", PHP_EOL;
bcscale((int) $scale);
}