komakino/identity 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

komakino/identity

Composer 安装命令:

composer require komakino/identity

包简介

Validation and property parsing of identity numbers

README 文档

README

Identity is a composer package to validate, parse, format and extract various information from national identity numbers.

Current implementations:

  • Swedish personnummer/organisationsnummer
  • Danish personnummer/CPR-nummer
  • Finnish henkilötunnus/personbeteckning
  • Norwegian fødselsnummer

Installation

To add this package as a dependency to your project, simply add a dependency on komakino/identity to your project's composer.json file.

    {
        "require": {
            "komakino/identity": "*"
        }
    }

Usage

use Komakino\Identity\National\SwedishIdentity;
use Komakino\Identity\National\DanishIdentity;

$swedishIdentity = new SwedishIdentity('011017-2721');
$danishIdentity = new DanishIdentity('170583-7315');

Common methods

Upon construction, the number is parsed and validated.

If number does not comply to the allowed input formats of the implementation, an IdentityInvalidFormatException will be thrown.

Public properties

  • bool $valid

    • The validity of the identity number
  • mixed **getters**

    • All number properties are accessible as properties on the instance

Public methods

  • array listProperties()

    • Returns all number properties
  • bool hasProperty(string $property)

    • Checks if the identity's implementation has a property
  • string __toString()

    • Output the formatted identity number

Static methods

  • static array parse(string $number)

    • Creates an instance and returns all number properties
  • static bool validate(string $number)

    • Creates an instance and returns the validity of the number
  • static string format(string $number)

    • Output the formatted identity number

Swedish personnummer/organisationsnummer

Allowed input formats

  • 0110172721
  • 011017-2721
  • 011017+2721
  • 200110172721
  • 20011017-2721
  • 20011017+2721

Formatted output

011017-2721

Number properties

  • type
    • organization or person
  • century
    • Sources for century:
      • Provided in number as OOxxxxxx-xxxx
      • The separator is a +, which denotes a person is over 100
      • By logical guessing. Pseudo: year > current_year ? 19 : 20
  • year
    • OOxxxx-xxxx
  • month
    • xxOOxx-xxxx
  • day
    • xxxxOO-xxxx
  • centuryHint
    • xxxxx**-**xxxx
    • Defaults to -
  • locality
    • xxxxxx-OOxx
  • county
    • Only available for people born before 1990
  • number
    • xxxxxx-xxOx
  • gender
    • male or female
  • checkdigit
    • xxxxxx-xxxO
  • birthday
    • A DateTime object
  • temporary
    • If the number is of a temporary nature

Danish personnummer/CPR-nummer

Allowed input formats

  • 1705837315
  • 170583-7315

Formatted output

170583-7315

Number properties

  • century
    • Calculated from year and centuryHint
  • day
    • OOxxxx-xxxx
  • month
    • xxOOxx-xxxx
  • year
    • xxxxOO-xxxx
  • centuryHint
    • xxxxxx-Oxxx
  • sequence
    • xxxxxx-OOO0
  • gender
    • male or female
  • birthday
    • A DateTime object

Finnish personnummer/CPR-nummer

Allowed input formats

  • 311280-888Y

Formatted output

311280-888Y

Number properties

  • century
    • Defined by centuryHint
  • day
    • OOxxxx-xxxx
  • month
    • xxOOxx-xxxx
  • year
    • xxxxOO-xxxx
  • centuryHint
    • xxxxx**-**xxxx
    • -/+/A
  • number
    • xxxxxx-OOOx
  • checkdigit
    • xxxxxx-xxxO
  • gender
    • male or female
  • birthday
    • A DateTime object

Norwegian fødselsnummer

Allowed input formats

  • 17058332143

Formatted output

17058332143

Number properties

  • century
    • Calculated from year and number
  • day
    • OOxxxxxxxxx
  • month
    • xxOOxxxxxxx
  • year
    • xxxxOOxxxxx
  • number
    • xxxxxxOOOxx
  • checkdigits
    • xxxxxxxxxOO
  • gender
    • male or female
  • birthday
    • A DateTime object
  • D-number
    • bool Whether or not this is a D-number. Temporary number provided to immigrants etc.
  • H-number
    • bool Whether or not this is a H-number. Temporary number used by health care etc.

Changelog

v1.3.0

  • Will now throw an exception if number does'nt comply to the implementations allowed input format.

v1.2.1

  • Fixed issues with parsing zeros.

v1.2.0

  • Added implementation for Norwegian fødselsnummer

v1.1.0

  • Added implementation for Finnish henkilötunnus/personbeteckning

v1.0.0

  • Initial public release
  • Added implementation for Swedish personnummer/organisationsnummer
  • Added implementation for Danish personnummer/CPR-nummer

komakino/identity 适用场景与选型建议

komakino/identity 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 200.07k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2016 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「number」 「identity」 「validate」 「Ssn」 「luhn」 「Swedish」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 komakino/identity 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 komakino/identity 我们能提供哪些服务?
定制开发 / 二次开发

基于 komakino/identity 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2016-01-14