承接 oriceon/cnp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

oriceon/cnp

最新稳定版本:1.0.0

Composer 安装命令:

composer require oriceon/cnp

包简介

Romanian CNP Validator

关键字:

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

Validates Personal Identification Number (CNP) for Romanian citizens and residents.

Valid format:

|S|YY|MM|DD|CC|XXX|C|

where

|S| - Gender number for:

1 = Male, born between 1900 - 1999

2 = Female, born between 1900 - 1999

3 = Male, born between 1800 - 1899

4 = Female, born between 1800 - 1899

5 = Male, born between 2000 - 2099

6 = Female, born between 2000 - 2099

7 = Male resident (century does not apply)

8 = Female resident (century does not apply)

|YY| - year of birth - 00 - 99

|MM| - birth month - 01 - 12

|DD| - birthday - 01 - 28/29/30/31

|CC| - county code - for a valid value check CNP::COUNTY_CODE

|XXX|- the serial number assigned to the person - 000 - 999

|C| - check Digit

See https://ro.wikipedia.org/wiki/Cod_numeric_personal

Installation

You can install the package via composer:

composer require oriceon/cnp

Usage

 use Oriceon\Cnp\Cnp;
 
 $cnpToValidate = 5110102441483;
 
 $cnp = new Cnp($cnpToValidate);
 if ($cnp->isValid()) {
      // extract info from CNP
      echo 'CNP ' . $cnpToValidate . ' - is valid' . PHP_EOL;
      echo 'Birth Date: ' . $cnp->getBirthDateFromCNP('Y/m/d') . ' (' . $cnp->getAgeInYears() . ' years) ' . PHP_EOL;
      echo 'Birthplace: ' . $cnp->getBirthCountyFromCNP() . PHP_EOL;
      echo 'Gender: ' . $cnp->getGenderFromCNP('male', 'female') . PHP_EOL;
      echo 'Person is ' . ($cnp->isPersonMajor() ? '' : 'not') . ' major' . PHP_EOL;
      echo 'Person have an Identity Card ' . ($cnp->hasIdentityCard() ? 'YES' : 'NO') . PHP_EOL;
      echo 'Person is resident ' . ($cnp->isResident() ? 'YES' : 'NO') . PHP_EOL;
 } else {
      echo 'CNP ' . $cnpToValidate . ' is invalid' . PHP_EOL;
 }
 
 // or call static
  echo 'CNP ' . $cnpToValidate . ' is ' . (Cnp::validate($cnpToValidate) ? 'valid' : 'invalid');

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email oriceon@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-23