定制 kerekit/hungarian-vat-number 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kerekit/hungarian-vat-number

Composer 安装命令:

composer require kerekit/hungarian-vat-number

包简介

A class for storing/parsing valid Hungarian VAT numbers.

README 文档

README

The VatNumber class parses a Hungarian VAT number in its local (not EU) format and throws an exception when the number is invalid.

Features (bugs?)

  • It checks validity against the check digit.
  • Provides enums for region and VAT codes. These are used for validation and may help with identification too.
  • The input is only accepted in a single strict format: ^\d{8}-\d-\d{2}$ (hyphens are required, no leading or trailing whitespace/junk is tolerated).

Examples

<?php

use Kerekit\HungarianVatNumber\{Exception,RegionCode,VatCode,VatNumber};

// Init a valid VAT number
$valid = new VatNumber ('12345676-1-41');

// Display it as string
echo "The VAT number is: $valid\n"; // The VAT number is: 12345676-1-41

// Check region
if ($valid->regionCode == RegionCode::ESZAK_BUDAPEST) {
    echo "The VAT number is related to Northern Budapest region.\n";
}

// Check VAT status
if ($valid->vatCode == VatCode::AAM) {
    echo "The owner of the VAT number is VAT exempt.\n";
}

// Trying to add a VAT number with wrong check-digit results in Exception
try {
    $invalid = new VatNumber ('12345678-1-41');
} catch (Exception $e) {
    $errno = $e->getCode ();
    if ($errno == Exception::INVALID_CHECK_DIGIT) {
        echo "The given check digit is wrong. Please try to type it again.\n";
    } else {
        echo "Please type the VAT number in the following regex format: ";
        echo VatNumber::FULL_PATTERN;
        echo "\n";
    }
    exit (1);
} catch (\Exception $e) {
    echo "An unexpected error occured.\n";
    exit (1);
}

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固