<?php

use LyraFinances\controller\Importer;

include('autoload.php');
include('vendor/autoload.php');
include('init.inc.php');

/**
 * the whole system works with something I'd call a Transfer object. It's basically a container (Payments) which
 * contains multiple Payments (objects of type Payment). This container is handed around in the application.
 */
$payments = new Payments();
/**
 * you'll attach a storage to the container which is used to create, retrieve, update and delete entries in the
 * container. Currently I've only implemented SqliteStorage.
 */
$payments->injectStorage(new SqliteStorage($db));

/**
 * Let's initialize the importer which will take care of the import procedure and fill the payments container.
 */
$importer = new Importer($payments);
/**
 * The importer accepts multiple parsers. Currently I've
 * implemented MT940 as well as CSV.
 */
$importer->injectParser(new Mt940Parser());
/**
 * CSV is not as simple as MT940 since every bank has a
 * quite different format. Hence you may inject CsvFilters.
 * Currently I've implemented Sparkasse, Volksbank as well
 * as Hibiscus. Not sure if the CSV of every Sparkasse
 * and every Volksbank are equal.
 */
$parser = new CsvParser();
$parser->injectFilter(new SparkasseCsvFilter());
$parser->injectFilter(new VolksbankCsvFilter());
$parser->injectFilter(new HibiscusCsvFilter());
$importer->injectParser($parser);