silarhi / caf-parser
A CAF Parser for LA44ZZ file
Requires
- php: >=8.2
Requires (Dev)
- ergebnis/composer-normalize: ^2.54.0
- friendsofphp/php-cs-fixer: ^3.95.27
- phpstan/phpstan: ^2.2.16
- phpstan/phpstan-strict-rules: ^2.0.12
- phpunit/phpunit: ^11.5.55 || ^12.0 || ^13.0
- rector/rector: ^2.6.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-06 17:01:20 UTC
README
CAF Parser
A PHP parser for CAF LA44ZZ payment slips.
Turn the plain-text "bordereau de paiement" sent by the Caisse d'Allocations Familiales into typed PHP objects.
Features
- LA44ZZ payment slips — parses every payment line of the table (beneficiary, period, gross, deduction and net amounts)
- Slip metadata — processing and payment dates, CAF name and address, recipient name and address, reference, BIC, IBAN and total
- Typed results — dates as
DateTimeInterface, amounts asfloat - French amount formats — a comma, when present, is the decimal separator; spaces, no-break spaces and dots are
thousands separators (
1 298,50,1.298,50and1298.50all give1298.5) - Strict validation — malformed rows and invalid or out-of-range dates throw a
ParseException - No dependencies — plain PHP, works with Windows (
\r\n) and Unix line endings
Requirements
| Dependency | Version |
|---|---|
| PHP | 8.2+ |
Installation
composer require silarhi/caf-parser
Usage
Parse a LA44ZZ file
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 }
What you get
PaymentSlip holds the slip metadata and its lines. Metadata getters return null when the information is missing from
the file:
| Getter | Type | Notes |
|---|---|---|
getProcessingDate(), getPaymentDate() |
?DateTimeInterface |
Full dates (d m Y), at midnight |
getCafName(), getCafAddress() |
?string |
e.g. CAISSE D'ALLOCATIONS FAMILIALES DE HAUTE GARONNE |
getRecipientName(), getRecipientAddress() |
?string |
The landlord receiving the payment |
getReference() |
?string |
NM REFERENCE of the slip |
getBic(), getIban() |
?string |
IBAN without spaces |
getTotalAmount() |
?float |
|
getLines() |
PaymentSlipLine[] |
Each PaymentSlipLine exposes getReference() (housing/loan reference, may be empty), getBeneficiaryReference(),
getBeneficiaryName(), getStartDate() and getEndDate() (the month of the period, as the 1st of the month at
midnight), and getGrossAmount(), getDeduction() and getNetAmount() as floats.
Error handling
parse() throws a ParseException when the content has no LA44ZZ payment table, when a row does not have the expected
columns, or when a date (row period or header date) is invalid or out of range: 13 2021 or 31 02 2021 are rejected
instead of being rolled over. Row errors carry the row number, e.g. CAF Row n°2 could not be parsed.
use Silarhi\Caf\Exceptions\ParseException; try { $paymentSlip = $parser->parse($content); } catch (ParseException $e) { // Not a LA44ZZ payment slip, malformed row or invalid date }
Testing & Quality
# Install dependencies composer install # Run tests vendor/bin/phpunit # Static analysis (level: max) vendor/bin/phpstan analyse # Code style check vendor/bin/php-cs-fixer fix --dry-run --diff # Code style fix vendor/bin/php-cs-fixer fix # Code modernization check vendor/bin/rector process --dry-run
Contributing
Contributions are welcome! Please make sure your changes pass all quality checks before submitting a pull request:
vendor/bin/phpunit && vendor/bin/phpstan analyse && vendor/bin/php-cs-fixer fix --dry-run --diff
License
MIT License. See LICENSE for details.
Built with care by SILARHI.
If CAF Parser saves you time, consider giving it a star on GitHub.