欧洲增值税率和号码验证。

1.1.0 2023-03-13 11:49 UTC

This package is auto-updated.

Last update: 2024-09-24 10:04:21 UTC


README

PHP的欧洲增值税工具

codecov GitHub Workflow Status Packagist PHP Version Support Packagist PHP Version Support Packagist Downloads

用法

composer require sandwave-io/vat
$vatService = new \SandwaveIo\Vat\Vat;

$vatService->validateEuropeanVatNumber("YOURVATNUMBERHERE", "COUNTRYCODE"); // true

$vatService->countryInEurope('NL'); // true

$vatService->europeanVatRate("YOURVATNUMBERHERE"); // 0.0

缓存

如果您经常为一个国家的增值税率进行解析,可能会稍微慢一些。如果您愿意,可以通过将 Psr\SimpleCache\CacheInterface 传递给 Vat() 服务来缓存结果。根据您的应用程序,实现可能会有所不同,但所有主流框架都在其缓存上实现了此接口。

/** @var Psr\SimpleCache\CacheInterface $cache */

$vatService = new \SandwaveIo\Vat\Vat(cache: $cache);

外部文档

如何贡献

如果您有任何改进的想法,请随意创建PR。或者创建一个问题。

  • 在添加代码时,请确保为其添加测试(phpunit)。
  • 确保代码符合我们的编码标准(使用php-cs-fixer进行检查/修复)。
  • 同时确保PHPStan没有找到任何错误。
vendor/bin/php-cs-fixer fix

vendor/bin/phpstan analyze

vendor/bin/phpunit --coverage-text

这些工具也会在GitHub actions上运行PR和master的push。

关于测试套件

还有一个集成测试,要跳过此(繁重)测试,请运行

vendor/bin/phpunit --exclude=large

我们使用PHPUnit生成覆盖率。在CI上,我们使用XDebug来完成。如果您已安装XDebug,您可以运行

vendor/bin/phpunit --coverage-text

# or generate an interactive report.
vendor/bin/phpunit --coverage-html=coverage_report

或者,您可以使用 PHPDBG 作为覆盖率驱动器

phpdbg -qrr vendor/bin/phpunit --coverage-text