PHPackages                             schema31/php-it-tax-code-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. schema31/php-it-tax-code-sdk

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

schema31/php-it-tax-code-sdk
============================

An italian tax code calculator and checker

v0.7.4(5y ago)014GPL-2.0-or-laterPHPPHP ^7.1

Since Nov 22Pushed 5y agoCompare

[ Source](https://github.com/Schema31/php-it-tax-code-sdk)[ Packagist](https://packagist.org/packages/schema31/php-it-tax-code-sdk)[ RSS](/packages/schema31-php-it-tax-code-sdk/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (2)Versions (20)Used By (0)

php-it-tax-code-sdk
===================

[](#php-it-tax-code-sdk)

[!\[Latest version\]\[ico-version\]](https://packagist.org/packages/schema31/php-it-tax-code-sdk)\[!\[Build Status\]\[ico-travis\]\]\[link-travis\] \[!\[Coverage Status\]\[ico-scrutinizer\]\]\[link-scrutinizer\] \[!\[Quality Score\]\[ico-code-quality\]\]\[link-code-quality\] \[!\[Total Downloads\]\[ico-downloads\]\]\[link-downloads\]

\[!\[PSR2 Conformance\]\[ico-styleci\]\]\[link-styleci\]

A PHP library to calculate and check the italian tax code (codice fiscale).

*Read this in [Italian](README-it.md).*

Install
-------

[](#install)

You can install the library using [composer](https://getcomposer.org/):

```
$ composer require schema31/php-it-tax-code-sdk
```

How to use
----------

[](#how-to-use)

### Calculate a codice fiscale

[](#calculate-a-codice-fiscale)

Use the calculator to calculate the codice fiscale.

```
use CodiceFiscale\Calculator;
use CodiceFiscale\Subject;

$subject = new Subject(
  array(
    "name" => "Mario",
    "surname" => "Rossi",
    "birthDate" => "1985-12-10",
    "gender" => "M",
    "belfioreCode" => "A562"
  )
);

$calculator = new Calculator($subject);
$codiceFiscale = $calculator->calculate();
echo $codiceFiscale; //"RSSMRA85T10A562S"
```

You can also add an array for additional configuration for the `Calculator`. Available array keys are:

- "omocodiaLevel": specifies the level of omocodia that the `Calculator` should consider.

```
use CodiceFiscale\Calculator;
use CodiceFiscale\Subject;

$subject = new Subject(
  array(
    "name" => "Mario",
    "surname" => "Rossi",
    "birthDate" => "1985-12-10",
    "gender" => "M",
    "belfioreCode" => "A562"
  )
);

$calculator = new Calculator($subject, array(
  "omocodiaLevel" => $omocodiaLevel
));
$codiceFiscale = $calculator->calculate();
echo $codiceFiscale; //"RSSMRA85T10A56NH"
```

You can also calculate all codici fiscali that a subject could have (using all 128 available levels).

```
use CodiceFiscale\Calculator;
use CodiceFiscale\Subject;

$subject = new Subject(
  array(
    "name" => "Mario",
    "surname" => "Rossi",
    "birthDate" => "1985-12-10",
    "gender" => "M",
    "belfioreCode" => "A562"
  )
);

$calculator = new Calculator($subject);
$codiciFiscali = $calculator->calculateAllPossibilities();
print_r($codiciFiscali);
/*
Array
(
    [0] => RSSMRA85T10A562S
    [1] => RSSMRA85T10A56NH
    [2] => RSSMRA85T10A5S2E
    [3] => RSSMRA85T10A5SNT
    [4] => RSSMRA85T10AR62N
    [5] => RSSMRA85T10AR6NC
    [6] => RSSMRA85T10ARS2Z
    [7] => RSSMRA85T10ARSNO
    [8] => RSSMRA85T1LA562V
    [9] => RSSMRA85T1LA56NK
    [10] => RSSMRA85T1LA5S2H
    [11] => RSSMRA85T1LA5SNW
    [12] => RSSMRA85T1LAR62Q
    [13] => RSSMRA85T1LAR6NF
    [14] => RSSMRA85T1LARS2C
    [15] => RSSMRA85T1LARSNR
    [16] => RSSMRA85TM0A562D
    [17] => RSSMRA85TM0A56NS
    [18] => RSSMRA85TM0A5S2P
    [19] => RSSMRA85TM0A5SNE
    [20] => RSSMRA85TM0AR62Y
    [21] => RSSMRA85TM0AR6NN
    [22] => RSSMRA85TM0ARS2K
    [23] => RSSMRA85TM0ARSNZ
    [24] => RSSMRA85TMLA562G
    [25] => RSSMRA85TMLA56NV
    [26] => RSSMRA85TMLA5S2S
    [27] => RSSMRA85TMLA5SNH
    [28] => RSSMRA85TMLAR62B
    [29] => RSSMRA85TMLAR6NQ
    [30] => RSSMRA85TMLARS2N
    [31] => RSSMRA85TMLARSNC
    [32] => RSSMRA8RT10A562E
    [33] => RSSMRA8RT10A56NT
    [34] => RSSMRA8RT10A5S2Q
    [35] => RSSMRA8RT10A5SNF
    [36] => RSSMRA8RT10AR62Z
    [37] => RSSMRA8RT10AR6NO
    [38] => RSSMRA8RT10ARS2L
    [39] => RSSMRA8RT10ARSNA
    [40] => RSSMRA8RT1LA562H
    [41] => RSSMRA8RT1LA56NW
    [42] => RSSMRA8RT1LA5S2T
    [43] => RSSMRA8RT1LA5SNI
    [44] => RSSMRA8RT1LAR62C
    [45] => RSSMRA8RT1LAR6NR
    [46] => RSSMRA8RT1LARS2O
    [47] => RSSMRA8RT1LARSND
    [48] => RSSMRA8RTM0A562P
    [49] => RSSMRA8RTM0A56NE
    [50] => RSSMRA8RTM0A5S2B
    [51] => RSSMRA8RTM0A5SNQ
    [52] => RSSMRA8RTM0AR62K
    [53] => RSSMRA8RTM0AR6NZ
    [54] => RSSMRA8RTM0ARS2W
    [55] => RSSMRA8RTM0ARSNL
    [56] => RSSMRA8RTMLA562S
    [57] => RSSMRA8RTMLA56NH
    [58] => RSSMRA8RTMLA5S2E
    [59] => RSSMRA8RTMLA5SNT
    [60] => RSSMRA8RTMLAR62N
    [61] => RSSMRA8RTMLAR6NC
    [62] => RSSMRA8RTMLARS2Z
    [63] => RSSMRA8RTMLARSNO
    [64] => RSSMRAU5T10A562P
    [65] => RSSMRAU5T10A56NE
    [66] => RSSMRAU5T10A5S2B
    [67] => RSSMRAU5T10A5SNQ
    [68] => RSSMRAU5T10AR62K
    [69] => RSSMRAU5T10AR6NZ
    [70] => RSSMRAU5T10ARS2W
    [71] => RSSMRAU5T10ARSNL
    [72] => RSSMRAU5T1LA562S
    [73] => RSSMRAU5T1LA56NH
    [74] => RSSMRAU5T1LA5S2E
    [75] => RSSMRAU5T1LA5SNT
    [76] => RSSMRAU5T1LAR62N
    [77] => RSSMRAU5T1LAR6NC
    [78] => RSSMRAU5T1LARS2Z
    [79] => RSSMRAU5T1LARSNO
    [80] => RSSMRAU5TM0A562A
    [81] => RSSMRAU5TM0A56NP
    [82] => RSSMRAU5TM0A5S2M
    [83] => RSSMRAU5TM0A5SNB
    [84] => RSSMRAU5TM0AR62V
    [85] => RSSMRAU5TM0AR6NK
    [86] => RSSMRAU5TM0ARS2H
    [87] => RSSMRAU5TM0ARSNW
    [88] => RSSMRAU5TMLA562D
    [89] => RSSMRAU5TMLA56NS
    [90] => RSSMRAU5TMLA5S2P
    [91] => RSSMRAU5TMLA5SNE
    [92] => RSSMRAU5TMLAR62Y
    [93] => RSSMRAU5TMLAR6NN
    [94] => RSSMRAU5TMLARS2K
    [95] => RSSMRAU5TMLARSNZ
    [96] => RSSMRAURT10A562B
    [97] => RSSMRAURT10A56NQ
    [98] => RSSMRAURT10A5S2N
    [99] => RSSMRAURT10A5SNC
    [100] => RSSMRAURT10AR62W
    [101] => RSSMRAURT10AR6NL
    [102] => RSSMRAURT10ARS2I
    [103] => RSSMRAURT10ARSNX
    [104] => RSSMRAURT1LA562E
    [105] => RSSMRAURT1LA56NT
    [106] => RSSMRAURT1LA5S2Q
    [107] => RSSMRAURT1LA5SNF
    [108] => RSSMRAURT1LAR62Z
    [109] => RSSMRAURT1LAR6NO
    [110] => RSSMRAURT1LARS2L
    [111] => RSSMRAURT1LARSNA
    [112] => RSSMRAURTM0A562M
    [113] => RSSMRAURTM0A56NB
    [114] => RSSMRAURTM0A5S2Y
    [115] => RSSMRAURTM0A5SNN
    [116] => RSSMRAURTM0AR62H
    [117] => RSSMRAURTM0AR6NW
    [118] => RSSMRAURTM0ARS2T
    [119] => RSSMRAURTM0ARSNI
    [120] => RSSMRAURTMLA562P
    [121] => RSSMRAURTMLA56NE
    [122] => RSSMRAURTMLA5S2B
    [123] => RSSMRAURTMLA5SNQ
    [124] => RSSMRAURTMLAR62K
    [125] => RSSMRAURTMLAR6NZ
    [126] => RSSMRAURTMLARS2W
    [127] => RSSMRAURTMLARSNL
)
*/
```

### Check if it is valid

[](#check-if-it-is-valid)

Use the checker to check if the given codice fiscale is ok for the given `Subject` and additional configuration. The additional configuration array for the `Checker` has the given available keys:

- "codiceFiscaleToCheck": the codice fiscale to check;
- "omocodiaLevel": the omocodia level to use to check.

```
use CodiceFiscale\Checker;
use CodiceFiscale\Subject;

$subject = new Subject(
  array(
    "name" => "Mario",
    "surname" => "Rossi",
    "birthDate" => "1985-12-10",
    "gender" => "M",
    "belfioreCode" => "A562"
  )
);

$checker = new Checker($subject, array(
  "codiceFiscaleToCheck" => "RSSMRA85T10A562S",
  "omocodiaLevel" => 0
));

$response = $checker->check();
echo $response; // true
```

You can also provide as `omocodiaLevel` key, the value of `Checker::ALL_OMOCODIA_LEVELS` that will check for all the possibilities for the given `Subject`. In the following example, the `Subject` would not be valid for the given codice fiscale, but it will be so, cause the check will iterate over all the possibilities for the different omocodia levels.

```
use CodiceFiscale\Checker;
use CodiceFiscale\Subject;

$subject = new Subject(
  array(
    "name" => "Roberto",
    "surname" => "Santi",
    "birthDate" => "1963-05-08",
    "gender" => "M",
    "belfioreCode" => "H501"
  )
);

$checker = new Checker($subject, array(
  "codiceFiscaleToCheck" => "SNTRRT63E08H50ML",
  "omocodiaLevel" => Checker::ALL_OMOCODIA_LEVELS
));

$response = $checker->check();
echo $response; // true
```

### Formal validation

[](#formal-validation)

Use the Validator to verify if the given codice fiscale is formally valid. The additional configuration array for the `Validator` has the given available keys:

- "omocodiaAllowed": whether to allow or not omocodia, defaults to true;
- "century": for people over 100 years old, it is not possibile to derive unambiguously birth year, so you can specify the century (for example '18' for a person birth in 1899). It allows to check birth date existence. Defaults to null (auto calculation of the century).

```
use CodiceFiscale\Validator;

$codiceFiscale = "RSSMRA85T10A562S";

$validator = new Validator($codiceFiscale);

$response = $validator->isFormallyValid();
echo $response; // true
```

### Inverse calculation

[](#inverse-calculation)

Use the InverseCalculator to extract birth date, gender and the belfiore code from the given codice fiscale. The additional configuration array for the `InverseCalculator` has the keys already described for the `Validator`.

```
use CodiceFiscale\InverseCalculator;

$codiceFiscale = "RSSMRA85T10A562S";

$inverseCalculator = new InverseCalculator($codiceFiscale);

$subject = $inverseCalculator->getSubject();
var_dump($subject);
// object(CodiceFiscale\Subject)[449]
//   private 'name' => null
//   private 'surname' => null
//   private 'birthDate' =>
//     object(DateTime)[452]
//       public 'date' => string '1985-12-10 00:00:00.000000' (length=26)
//       public 'timezone_type' => int 3
//       public 'timezone' => string 'Europe/Berlin' (length=13)
//   private 'gender' => string 'M' (length=1)
//   private 'belfioreCode' => string 'A562' (length=4)
```

Test
----

[](#test)

```
$ vendor\bin\phpunit
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~96 days

Recently: every ~43 days

Total

19

Last Release

2087d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/848636d8da9389154acabd22a7fc46a7b876730adff2070e56a19d1d89f90af6?d=identicon)[gabriele120987](/maintainers/gabriele120987)

---

Top Contributors

[![DavidePastore](https://avatars.githubusercontent.com/u/1949364?v=4)](https://github.com/DavidePastore "DavidePastore (74 commits)")[![antonioturdo](https://avatars.githubusercontent.com/u/1651072?v=4)](https://github.com/antonioturdo "antonioturdo (27 commits)")[![giorgioma](https://avatars.githubusercontent.com/u/7810053?v=4)](https://github.com/giorgioma "giorgioma (6 commits)")[![gabriele120987](https://avatars.githubusercontent.com/u/12832122?v=4)](https://github.com/gabriele120987 "gabriele120987 (6 commits)")[![tvinterlogica](https://avatars.githubusercontent.com/u/132082820?v=4)](https://github.com/tvinterlogica "tvinterlogica (2 commits)")[![gadiener](https://avatars.githubusercontent.com/u/8479033?v=4)](https://github.com/gadiener "gadiener (1 commits)")[![angelods](https://avatars.githubusercontent.com/u/19353647?v=4)](https://github.com/angelods "angelods (1 commits)")[![garak](https://avatars.githubusercontent.com/u/179866?v=4)](https://github.com/garak "garak (1 commits)")[![loviuz](https://avatars.githubusercontent.com/u/1647128?v=4)](https://github.com/loviuz "loviuz (1 commits)")

---

Tags

validatorcodice fiscaletax codeitalianitaly

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/schema31-php-it-tax-code-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/schema31-php-it-tax-code-sdk/health.svg)](https://phpackages.com/packages/schema31-php-it-tax-code-sdk)
```

###  Alternatives

[davidepastore/codice-fiscale

An italian tax code calculator and checker

104815.0k6](/packages/davidepastore-codice-fiscale)[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[seld/jsonlint

JSON Linter

1.3k217.8M205](/packages/seld-jsonlint)[composer/spdx-licenses

SPDX licenses list and validation library.

1.4k184.2M25](/packages/composer-spdx-licenses)[opis/json-schema

Json Schema Validator for PHP

64236.9M186](/packages/opis-json-schema)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
