carloswph/valium-pt

针对葡萄牙市场的验证。

v1.1.0 2021-04-14 12:09 UTC

This package is auto-updated.

Last update: 2024-09-16 04:03:40 UTC


README

Valium 是一个旨在为不同国家的公共和官方号码和代码提供验证类的 PHP 初始化项目。这个特定的库专注于葡萄牙市场。此包已经成功验证了以下号码

  • NIF/NIPC
  • NISS
  • IBAN
  • BI

用法

每种类型的号码都有自己的类,可以通过实例化相应的类并使用带有待验证号码/代码数组的 check() 方法来使用。该方法返回一个包含代码作为键和布尔检查值作为值的数组。对于 NIF,该方法还接受第二个参数(默认为 false)。如果为 TRUE,第二个参数不仅验证 NIF 号码,还返回纳税人类型的描述,而不是布尔结果。

use Valium\PT\Nif;
use Valium\PT\Niss;
use Valium\PT\Iban;
use Valium\PT\Bi;

require __DIR__ . '/vendor/autoload.php';

$nif = new Nif();
// Returns a bool for each number in the array
$q = $nif->check([720014360, '291653170', 980547490, 281234500, 510837620]);
// Returns the type of tax payer for each valid number
$r = $nif->check([292679411, '720014360', 980547490, 281234500, 510837620], true);

var_dump($q);
var_dump($r);

$niss = new Niss();
// Returns a bool for each number in the array
$s = $niss->check([12060903799, 12073833086, 12060904475]);

var_dump($s);

$iban = new Iban();
// Returns a bool for each account in the array
$t = $iban->check(['PT50003300004549519501405', 'PT50001200004549519501405']);

var_dump($t);

$bi = new Bi();
// As an input, an array of the BI numbers together with the control digit (the first number before the two letters, XX, XY, i.e)
$x = $bi->check(['108015750', '34521320']);

var_dump($x);