PHPackages                             vimishor/cnp-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. vimishor/cnp-php

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

vimishor/cnp-php
================

Personal Identification Number (Cod Numeric Personal) validation

0.2.0(6y ago)12.3k2[1 PRs](https://github.com/vimishor/cnp-php/pulls)MITPHPPHP ~5.6|~7.0CI failing

Since Aug 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/vimishor/cnp-php)[ Packagist](https://packagist.org/packages/vimishor/cnp-php)[ Docs](https://github.com/vimishor/cnp-php)[ RSS](/packages/vimishor-cnp-php/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

Personal Identification Number validation
=========================================

[](#personal-identification-number-validation)

[![Latest Version](https://camo.githubusercontent.com/d90b37a70dffd9ae43e9ceaa9436af28bac6ec05a29a9a56d42e7438ce58c2bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76696d6973686f722f636e702d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vimishor/cnp-php)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/9c2a9c54238f23e0811b1f3070f5757653e260b758376d30120779714538f938/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f76696d6973686f722f636e702d7068702f646576656c6f702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/vimishor/cnp-php)[![Coverage Status](https://camo.githubusercontent.com/df0f99f74a1dabf8a06f4cd729f2c318e1bc7e3828aabbd4e2673592672a6bda/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f76696d6973686f722f636e702d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vimishor/cnp-php/?branch=develop)[![Code quality](https://camo.githubusercontent.com/280f603cefa282d95eeee9667222ac82248987f67e10a7043c4522dae358343c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f76696d6973686f722f636e702d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vimishor/cnp-php/?branch=develop)

PHP implementation of [Personal Identification Number specification - draft 0.1](https://github.com/vimishor/cnp-spec), in order to validate Personal Identification Number of Romanian citizens and residents.

Install
-------

[](#install)

Via Composer

```
$ composer require vimishor/cnp-php
```

Usage
-----

[](#usage)

```
use Gentle\Embeddable\Date;
use Vimishor\Cnp\Checksum;
use Vimishor\Cnp\Cnp;
use Vimishor\Cnp\County;
use Vimishor\Cnp\Gender;
use Vimishor\Cnp\Serial;

try {
    $cnp = Cnp::fromString('2791219470034');
} catch (\Vimishor\Cnp\Exception\InvalidCnpException $e) {
    // do something
}

// you can also instantiate everything yourself
try {
    $cnp = new Cnp(
        new Gender(2), Date::fromString('1979-12-19T19:10:23+00:00'), new County(47), new Serial(003), new Checksum(4)
    );
} catch (\Vimishor\Cnp\Exception\InvalidCnpException $e) {
    // do something
}
```

Testing
-------

[](#testing)

```
$ make test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

For any security related issues, please email send an email at [alex@gentle.ro](https://keybase.io/vimishor/key.asc) instead of using the issue tracker.

License
-------

[](#license)

Licensed under the MIT License - see the LICENSE file for details.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~804 days

Total

2

Last Release

2395d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d360d7a6070deb0054128aeabde12eb5fa070481eb42fd747f63c17ccb0b863?d=identicon)[vimishor](/maintainers/vimishor)

---

Top Contributors

[![vimishor](https://avatars.githubusercontent.com/u/477960?v=4)](https://github.com/vimishor "vimishor (23 commits)")

---

Tags

cnpromaniavalidationidentificationCNPRomania

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/vimishor-cnp-php/health.svg)

```
[![Health](https://phpackages.com/badges/vimishor-cnp-php/health.svg)](https://phpackages.com/packages/vimishor-cnp-php)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)[xemlock/htmlpurifier-html5

HTML5 support for HTML Purifier

1052.9M11](/packages/xemlock-htmlpurifier-html5)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
