定制 devsmo/php-hetu 二次开发

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

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

devsmo/php-hetu

最新稳定版本:v1.2.0

Composer 安装命令:

composer require devsmo/php-hetu

包简介

PHP Hetu validator. Hetu stands for Henkilötunnus aka Finnish Social Security Number

README 文档

README

codecov

Finnish Social Security number validator.

This simple class validates social security numbers and provides methods for checking birthdate, age and gender based on the 'hetu'.

Requirements

  • PHP >= 8.0

Installation

The recommended way is to install the lib through Composer.

composer require devsmo/php-hetu

Or you can add this to your composer.json

{
    "require": {
        "devsmo/php-hetu": "^1.0"
    }
}

Usage

The hetu class creates an immutable value object. You can initialize the object in two ways:

<?php

$hetu = Devsmo\Hetu::create('041281-981T');

if ( $hetu ) {
	echo "It's valid";
}
else {
	echo "It's not valid...";
}

Or if you want to catch possible errors:

<?php

try {
	$hetu = new Devsmo\Hetu('041281-981T');
}
catch (\InvalidArgumentException $e){
	$msg = $e->getMessage();
}

The class has three methods:

<?php
$age = $hetu->getAge(); // 35

$date_of_birth = $hetu->getDateStr(); // 1981-12-04

$gender = $hetu->getGender(); // male

Contribution

Feel free to contribute! Just create a new issue or a new pull request.

License

This library is released under the MIT License.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-22