-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.php
executable file
·47 lines (32 loc) · 1.22 KB
/
convert.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
<?php
require __DIR__ . '/vendor/autoload.php';
use Dotenv\Dotenv;
use Monolog\Logger;
use Src\CsvDataParser;
use Monolog\Handler\StreamHandler;
use Src\Migrations\CollectionsMigration;
$log = new Logger('Dataswitcher Tech Challenge');
$log->pushHandler(new StreamHandler('app.log', Logger::DEBUG));
$log->info('Running Conversion');
// CALL YOUR CODE HERE
$startTime = microtime(true);
$log->info(':: Reading .env file...');
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$log->info('::' . $_ENV['APP_NAME'] . ' v.' . $_ENV['APP_VERSION'] );
$log->info(':: Running Database Migrations...');
CollectionsMigration::run();
$log->info(':: Parse Data Folder...');
$parser = new CsvDataParser($_ENV['CSV_FOLDER']);
$files = $parser->getCsvFileNames();
$log->info(' » Detected files with data: ' . implode(', ', $files));
$log->info(':: Processing Data & Logic Started...');
$parser->parse();
$log->info(':: Processing Data & Logic Ended...');
$log->info(':: Updating Account Balance Values...');
$parser->updateAccountBalance();
$elapsedTime = microtime(true) - $startTime;
$log->info("Total execution time: {$elapsedTime} seconds");
// END YOUR CALL HERE
$log->info('Ended Conversion');
echo "\nConversion Finished!\n";