midassoft/dominicanbankparser

Dominican Bank parser

v1.0.3 2018-10-25 21:02 UTC

This package is not auto-updated.

Last update: 2024-05-17 01:08:01 UTC


README

This package allows you to parse files from the major dominican Bank entities.

Scrutinizer Code Quality Code Coverage Build Status Build Status StyleCI

Requirements

PHP ^7.1.3

Installation

composer require "midassoft/dominicanbankparser"

Usage

Just select the parser you want to use and call the parse method with the file content.

use MidasSoft\DominicanBankParser\Files\CSV;
use MidasSoft\DominicanBankParser\Parsers\BHDBankParser;

$parser = new BHDBankParser();
$file = file_get_contents(__DIR__.'/bhd_bank_file.csv');
$result = $parser->parse(new CSV($file));

This will return a collection of Deposit objects.

object(MidasSoft\DominicanBankParser\Collections\DepositCollection)#302 (1) {
  ["items":protected]=>
  array(91) {
    [0]=>
    object(MidasSoft\DominicanBankParser\Deposit)#23 (4) {
      ["amount":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(7) "4000.00"
      ["date":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(10) "19/12/2017"
      ["description":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(15) "DEPOSITO:3228-4"
      ["term":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(15) "DEPOSITO:3228-4"
    }
    [1]=>
    object(MidasSoft\DominicanBankParser\Deposit)#24 (4) {
      ["amount":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(8) "11805.00"
      ["date":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(10) "19/12/2017"
      ["description":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(19) "DEPOSITO:6051-7/195"
      ["term":"MidasSoft\DominicanBankParser\Deposit":private]=>
      string(19) "DEPOSITO:6051-7/195"
    }
  }
}

You can especify a cache manager in your parser if you want your data to persist , every parse will be automatically cached.

use MidasSoft\DominicanBankParser\Files\CSV;
use MidasSoft\DominicanBankParser\Parsers\BHDBankParser;

$parser = new BHDBankParser(new FileCacheDriver([
    'path' => __DIR__.'/cache',
    'timezone' => 'America/Santo_Domingo',
]));

$file = file_get_contents(__DIR__.'/bhd_bank_file.csv');
$result = $parser->parse(new CSV($file));
$cacheKeys = $parser->getCacheManager()->getKeys();
$parsedFromCache = $parser->getCacheManager()->get(end($cacheKeys));

There's two cache driver available ArrayCacheDriver and FileCacheDriver. When you use the FileCacheDriver you need to specify the path and timezone within your configuration.

Also you can write your own parsers by extending the MidasSoft\DominicanBankParser\Parsers\AbstractParser class, and your own cache drivers by extending MidasSoft\DominicanBankParser\Cache\AbstractCacheDriver.

Supported banks

  • BHD
  • Popular
  • Reservas
  • Santa Cruz