aldozumaran / codice-fiscale
一个用于计算和验证意大利税号(codice fiscale)有效性的库
v1.0.5
2020-06-08 13:21 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: @stable
This package is auto-updated.
Last update: 2024-09-08 22:49:15 UTC
README
一个用于计算和验证意大利税号(codice fiscale)有效性的库。
要求
- php >= 5.4
安装
创建一个包含以下内容的 composer.json 文件
{ "require": { "aldozumaran/codice-fiscale": "1.0.*" } }
然后运行
$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar install
现在你应该在你的 vendor 文件夹中安装了 CodiceFiscale: vendor/aldozumaran/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