-
-
Notifications
You must be signed in to change notification settings - Fork 78
/
phpunit.php
51 lines (38 loc) · 1.21 KB
/
phpunit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
use Brick\Math\Internal\Calculator;
require __DIR__ . '/vendor/autoload.php';
/**
* @return Calculator
*/
function getCalculatorImplementation()
{
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;
}
Calculator::set(getCalculatorImplementation());
$scale = \getenv('BCMATH_DEFAULT_SCALE');
if ($scale !== false) {
echo "Using bcscale($scale)", PHP_EOL;
\bcscale((int) $scale);
}