-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc.php
32 lines (26 loc) · 1.12 KB
/
calc.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
<?php
declare(strict_types=1);
use CommissionCalc\Calculator\CorrectAmountsCalculator;
use CommissionCalc\Calculator\Exceptions\InfrastructureException;
use CommissionCalc\Calculator\Exceptions\UnexpectedInputException;
use CommissionCalc\Infrastructure\BinLookupBinInfoProvider;
use CommissionCalc\Infrastructure\ExchangeRatesCurrenciesRatesProvider;
use CommissionCalc\Infrastructure\FileTransactionsProvider;
use CommissionCalc\Infrastructure\StaticCommissionValuesProvider;
require 'bootstrap.php';
$calculator = new CorrectAmountsCalculator(
transactionsProvider: new FileTransactionsProvider($argv[1]),
commissionValuesProvider: new StaticCommissionValuesProvider(),
binInfoProvider: new BinLookupBinInfoProvider(),
curRatesProvider: new ExchangeRatesCurrenciesRatesProvider()
);
try {
$correctedAmounts = $calculator->calculateCorrectedAmounts();
} catch (UnexpectedInputException $e) {
echo 'Invalid input: ' . $e->getMessage() . "\n";
exit(1);
} catch (InfrastructureException $e) {
echo 'Infrastructure error: ' . $e->getMessage() . "\n";
exit(1);
}
echo implode("\n", $correctedAmounts) . "\n";