Download the PHP package pontedilana/codice-fiscale without Composer
On this page you can find all versions of the php package pontedilana/codice-fiscale. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pontedilana/codice-fiscale
More information about pontedilana/codice-fiscale
Files in pontedilana/codice-fiscale
Package codice-fiscale
Short Description A library to calculate and check the validity of the italian fiscal code (codice fiscale)
License MIT
Informations about the package codice-fiscale
CodiceFiscale
A library to calculate and check the validity of the Italian fiscal code (codice fiscale). Based on the original work of andreausu, with the contribution of fdisotto.
Requirements
- php >= 8.1
- ext-intl
Installation
Add the library with the following command
How to use
Calculator::calcola() throws \InvalidArgumentException when the sex is not M or F
(case-insensitive) or the codice comune is not a letter followed by three digits.
The codice comune is trimmed and uppercased before use.
Checker::getError() returns one of these messages after a failed check:
| Message | Cause |
|---|---|
Empty code |
the code is empty |
Length error |
the code is not 16 characters long |
Code with wrong char |
the code does not match the expected pattern |
Wrong code |
the control character is wrong |
Wrong birth date |
the encoded birth date does not exist (e.g. day 00, 31 February) |
The century is not encoded in the fiscal code, so 29 February is accepted for every year divisible by 4.
Upgrading from 2.x
Calculator::calcola()now throws\InvalidArgumentExceptionfor an invalid sex or codice comune. In 2.x it returned a wrong code (any sex other thanFwas treated as male, a lowercase codice comune produced a wrong control character).Checker::isFormallyCorrect()now returnsfalse, with the errorWrong birth date, for codes that encode an impossible birth date. In 2.x these codes were accepted.
Testing
The library is fully tested with PHPUnit.
Go to the root folder, install the dev dependencies with composer, and then run the phpunit test suite
All versions of codice-fiscale with dependencies
ext-intl Version *