silarhi / cfonb-parser
A PHP Parser for CFONB transactions with zero dependencies
Installs: 28 388
Dependents: 0
Suggesters: 1
Security: 0
Stars: 10
Watchers: 4
Forks: 6
Open Issues: 0
Requires
- php: >=8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^1.12.9
- phpunit/phpunit: ^10.5.26
- rector/rector: ^1.2
- vimeo/psalm: ^5.26
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); }