-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
38 lines (30 loc) · 981 Bytes
/
index.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
<?php
require_once __DIR__.'/vendor/autoload.php';
use \lib\FileSystem\FileHandler;
use \lib\FileSystem\CSVFileReader;
use \lib\UseCase\BillSplitter;
use \lib\UseCase\BillSplitter\HeaderExtractor;
use \lib\UseCase\BillSplitter\Calculator;
use \lib\UseCase\BillSplitter\DataValidator;
use \lib\Template\MoneyOweDisplay;
$fileName = 'data/test1.txt';
$fileHandler = new FileHandler();
try {
$fileHandle = $fileHandler->open($fileName);
} catch (\Exception $e) {
echo $e->getMessage();
die;
}
$fileReader = new CSVFileReader($fileHandler);
$dataValidator = new DataValidator();
$headerExtractor = new HeaderExtractor($fileReader, $dataValidator);
$calculator = new Calculator($fileReader, $dataValidator);
$billSplitter = new BillSplitter($headerExtractor, $calculator);
try {
$splitData = $billSplitter->splitMoneyEqually();
} catch (\Exception $e) {
echo $e->getMessage();
die;
}
$display = new MoneyOweDisplay();
echo $display->display($splitData);