Link.FYI

Pastebin

Create New My Pastes

Code (PHP) pasted on 2019-01-16, 17:59 Raw Source

  1. <?php
  2.  
  3. use LyraFinances\controller\Importer;
  4.  
  5. include('autoload.php');
  6. include('vendor/autoload.php');
  7. include('init.inc.php');
  8.  
  9. /**
  10.  * the whole system works with something I'd call a Transfer object. It's basically a container (Payments) which
  11.  * contains multiple Payments (objects of type Payment). This container is handed around in the application.
  12.  */
  13. $payments = new Payments();
  14. /**
  15.  * you'll attach a storage to the container which is used to create, retrieve, update and delete entries in the
  16.  * container. Currently I've only implemented SqliteStorage.
  17.  */
  18. $payments->injectStorage(new SqliteStorage($db));
  19.  
  20. /**
  21.  * Let's initialize the importer which will take care of the import procedure and fill the payments container.
  22.  */
  23. $importer = new Importer($payments);
  24. /**
  25.  * The importer accepts multiple parsers. Currently I've
  26.  * implemented MT940 as well as CSV.
  27.  */
  28. $importer->injectParser(new Mt940Parser());
  29. /**
  30.  * CSV is not as simple as MT940 since every bank has a
  31.  * quite different format. Hence you may inject CsvFilters.
  32.  * Currently I've implemented Sparkasse, Volksbank as well
  33.  * as Hibiscus. Not sure if the CSV of every Sparkasse
  34.  * and every Volksbank are equal.
  35.  */
  36. $parser = new CsvParser();
  37. $parser->injectFilter(new SparkasseCsvFilter());
  38. $parser->injectFilter(new VolksbankCsvFilter());
  39. $parser->injectFilter(new HibiscusCsvFilter());
  40. $importer->injectParser($parser);
  41.  
  42.