Jacek Kowalski
2019-06-21 f6f79198b6467435fd7caccd2067eb0a29c97787
lib/output.php
@@ -1,4 +1,21 @@
<?php
function createMapping($db, $mapFunction, $saveConfig = FALSE) {
   $mapping = [];
   foreach($db->getAll() as $vehicle) {
      $mapping[$vehicle['id']] = $mapFunction($vehicle['num']);
   }
   if($saveConfig) {
      $json = json_encode($mapping);
      if(!file_put_contents($saveConfig['result_temp'], $json)) {
         throw new Exception('Result save failed');
      }
      rename($saveConfig['result_temp'], $saveConfig['result']);
   }
   return $mapping;
}
function createVehiclesList($trips, $mapping, $saveConfig = FALSE) {
   $lines = [];
   foreach($trips as $trip) {