silarhi / cfonb-parser
A PHP Parser for CFONB transactions with zero dependencies
Installs: 27 818
Dependents: 0
Suggesters: 1
Security: 0
Stars: 10
Watchers: 4
Forks: 6
Open Issues: 1
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.40
- phpstan/phpstan: ^1.10.47
- phpunit/phpunit: ^10.5.1
- rector/rector: ^0.18
- vimeo/psalm: ^5.16
README
A zero dependencies PHP Parser for CFONB statements
Supports CFONB 120/240 format
Installation
The preferred method of installation is via Composer. Run the following
command to install the package and add it as a requirement to your project's
composer.json
:
composer require silarhi/cfonb-parser
How to use
Parse CFONB 120
<?php use Silarhi\Cfonb\Cfonb120Reader; $reader = new Cfonb120Reader(); //Gets all statements day by day foreach($reader->parse('My Content') as $statement) { if ($statement->hasOldBalance()) { echo sprintf("Old balance : %f\n", $statement->getOldBalance()->getAmount()); } foreach($statement->getOperations() as $operation) { //Gets all statement operations } if ($statement->hasNewBalance()) { echo sprintf("New balance : %f\n", $statement->getNewBalance()->getAmount()); } }
Parse CFONB 240
<?php use Silarhi\Cfonb\Cfonb240Reader; $reader = new Cfonb240Reader(); foreach($reader->parse('My Content') as $transfer) { assert($transfer instanceof \Silarhi\Cfonb\Banking\Transfer); }
Parse both CFONB 120 and CFONB 240
<?php use Silarhi\Cfonb\CfonbReader; $reader = new CfonbReader(); foreach($reader->parseCfonb120('My Content') as $statement) { assert($statement instanceof \Silarhi\Cfonb\Banking\Statement); } foreach($reader->parseCfonb240('My Content') as $transfer) { assert($transfer instanceof \Silarhi\Cfonb\Banking\Transfer); }