ivanomatteo / codice-fiscale
意大利税号(codice fiscale)的计算和数据处理,支持“同音码”和变音字符扩展(caratteri diacritici)
0.1.9
2021-01-22 13:39 UTC
Requires (Dev)
- orchestra/testbench: ^4.0
- phpunit/phpunit: ^8.0
README
意大利税号(codice fiscale)的计算和数据处理,支持“同音码”。
它还支持变音字符扩展(caratteri diacritici),例如
'Ä' => 'AE', 'ß' => 'SS'
...
安装
您可以通过composer安装此软件包
composer require ivanomatteo/codice-fiscale
用法
include __DIR__.'/vendor/autoload.php'; use IvanoMatteo\CodiceFiscale\CodiceFiscale; try{ // will raise an exception if the format is not valid $c = CodiceFiscale::parse("RSSMRAULRL1H50MM",1900); // passing the "century" arg, help to validate in case of leap years $c = CodiceFiscale::parse("RSSMRAULRL1H50MM"); echo "\n"."matchName ".($c->matchName('Mario')? 'si' : 'no'); echo "\n"."isOmocodia ".($c->isOmocodia()? 'si' : 'no'); // to extract the date of birth, the "century" argumenti is required echo "\n"."getDateOfBirth ".$c->getDateOfBirth(1900)->format('Y-m-d'); // is possible to extract the raw date of birth: { "year":"yy", "month":"mm", "day":"dd" } echo "\n"."getDateOfBirthObj ".json_encode($c->getDateOfBirthRaw()); // the library can provide the nearest date of birth according to current date: echo "\n"."getProbableDateOfBirth ".$c->getProbableDateOfBirth()->format('Y-m-d'); // also according to minimum age and current date arguments echo "\n"."getProbableDateOfBirth 18 ".$c->getProbableDateOfBirth(18,'2019-01-01')->format('Y-m-d'); }catch(\Exception $ex){ echo $ex->getMessage(); } // // calculate using person data // $name = 'Mario'; $familyName = 'Rossi'; $dateOfBirth = '1980-10-01'; $sex = 'M'; $cityCode = 'H501'; $cf = CodiceFiscale::calculate($name, $familyName, $dateOfBirth, $sex, $cityCode); // // calcumate using an array (it accept an object as well) // $person = [ 'name' => $name, 'familyName' => $familyName, 'date' => $dateOfBirth, 'sex' => $sex, 'cityCode' => $cityCode, ]; $map = [ // it possible to provide a map, to match fields with different names 'dateOfBirth' => 'date' ]; $cfx = CodiceFiscale::calculateObj($person, $map); // generate all the 127 possible "omocodia" variations $variazioni = $cf->generateVariations(); // generate variation n. 7 only $variazioni = $cf->generateVariations(7);
测试
composer test
变更日志
请参阅变更日志以获取最近更改的更多信息。
贡献
请参阅贡献指南以获取详细信息。
安全性
如果您发现任何与安全性相关的问题,请通过电子邮件ivanomatteo@gmail.com联系,而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。