PHP code example of silarhi / caf-parser
1. Go to this page and download the library: Download silarhi/caf-parser library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
silarhi / caf-parser example snippets
use Silarhi\Caf\Parser\PaymentSlipParser;
$parser = new PaymentSlipParser();
$paymentSlip = $parser->parse(file_get_contents('/path/to/LA44ZZ.txt'));
foreach ($paymentSlip->getLines() as $line) {
$line->getBeneficiaryReference(); // e.g. "1111111 J"
$line->getBeneficiaryName(); // e.g. "MME JESUS"
$line->getStartDate(); // DateTimeInterface, 1st of the month at midnight
$line->getEndDate(); // DateTimeInterface, 1st of the month at midnight
$line->getNetAmount(); // e.g. 33.0
}
use Silarhi\Caf\Exceptions\ParseException;
try {
$paymentSlip = $parser->parse($content);
} catch (ParseException $e) {
// Not a LA44ZZ payment slip, malformed row or invalid date
}