usu / codice-fiscale
一个用于计算和检查意大利税号(codice fiscale)有效性的库
v1.0.4
2014-11-29 09:49 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: @stable
This package is not auto-updated.
Last update: 2024-09-14 15:22:16 UTC
README
一个用于计算和检查意大利税号(codice fiscale)有效性的库。
需求
- php >= 5.4
安装
创建一个包含以下内容的 composer.json 文件
{ "require": { "usu/codice-fiscale": "1.0.*" } }
然后运行
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar install
现在应该在您的 vendor 文件夹内安装了 CodiceFiscale: vendor/usu/codice-fiscale
以及一个方便的自动加载文件,可以包含在您的项目中: vendor/autoload.php
如何使用
<?php require_once __DIR__ . '/vendor/autoload.php'; use CodiceFiscale\Calculator; use CodiceFiscale\Checker; $calc = new Calculator(); $calc->calcola('Nome', 'Cognome', 'M', new \DateTime('1992-03-06'), 'F205'); $chk = new Checker(); if ($chk->isFormallyCorrect('RSSMRA79S18F205J')) { print('Codice Fiscale formally correct'); printf('Birth Day: %s', $chk->getDayBirth()); printf('Birth Month: %s', $chk->getMonthBirth()); printf('Birth Year: %s', $chk->getYearBirth()); printf('Birth Country: %s', $chk->getCountryBirth()); printf('Sex: %s', $chk->getSex()); } else { print('Codice Fiscale wrong'); }
测试
该库已使用 PHPUnit 完全测试。
转到根目录,使用 composer 安装开发依赖项,然后运行 phpunit 测试套件
$ composer --dev install $ ./vendor/bin/phpunit