-
Notifications
You must be signed in to change notification settings - Fork 0
/
Runner.php
39 lines (30 loc) · 1.14 KB
/
Runner.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
<?php declare(strict_types=1);
const INPUT_FILE_PREFIX = __DIR__ . '/src/';
include __DIR__ . '/Loader/Loader.php';
include __DIR__ . '/Processor/Processor.php';
include __DIR__ . '/Writer/Writer.php';
$loader = new Loader();
$processor = new Processor();
$writer = new Writer();
$filesToProcess = $loader->getFilesToProcess();
echo 'Choose files to process:' . PHP_EOL;
$loader->printFilesToProcess($filesToProcess);
$userInput = readline();
echo 'Processing data......' . PHP_EOL;
if ($userInput === 'a'){
foreach($filesToProcess as $file) {
$unprocessedData = $loader->load(INPUT_FILE_PREFIX . $file);
$processedData =$processor->process($unprocessedData);
$writer->write($processedData, $unprocessedData->getName());
}
} else {
$userInput = (int) $userInput;
$unprocessedData = $loader->load(INPUT_FILE_PREFIX . $filesToProcess[$userInput]);
$processedData =$processor->process($unprocessedData);
$writer->write($processedData, $unprocessedData->getName());
}
echo 'Process finished!' . PHP_EOL . PHP_EOL;
echo 'Zipping files......' . PHP_EOL;
$writer->zip();
echo 'Files zipped!' . PHP_EOL;
echo 'Success!';