PHPackages                             oriceon/cnp - 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. oriceon/cnp

ActiveLibrary

oriceon/cnp
===========

Romanian CNP Validator

1.0.0(1y ago)01MITPHPPHP ^8.3CI failing

Since Apr 23Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Romanian CNP Validator
======================

[](#romanian-cnp-validator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a3556ecac24760319954a83af54a5f2adba4974555d4f549ac000cc26e480c8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f726963656f6e2f636e702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oriceon/cnp)[![Total Downloads](https://camo.githubusercontent.com/8b5395bbeb469fbf6ffbd669917c4911347784a6c4d1467ba79b17b58d7407f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726963656f6e2f636e702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oriceon/cnp)[![GitHub Actions](https://github.com/oriceon/cnp/actions/workflows/main.yml/badge.svg)](https://github.com/oriceon/cnp/actions/workflows/main.yml/badge.svg)

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](https://ro.wikipedia.org/wiki/Cod_numeric_personal)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require oriceon/cnp
```

Usage
-----

[](#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

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

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

### Security

[](#security)

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

Credits
-------

[](#credits)

- [Valentin Ivașcu](https://github.com/oriceon)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance47

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

390d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a9692bf91992f959404944cecec65e1b68b21491ec3c5642e67e47a836d9ea8?d=identicon)[oriceon](/maintainers/oriceon)

---

Top Contributors

[![oriceon](https://avatars.githubusercontent.com/u/358823?v=4)](https://github.com/oriceon "oriceon (1 commits)")

---

Tags

CNPoriceon

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[litle/payments-sdk

The Vantiv eCommerce PHP SDK is a PHP implementation of the \[Vantiv eCommerce\](https://developer.vantiv.com/community/ecommerce). XML API. This SDK was created to make it as easy as possible to connect process your payments with Vantiv eCommerce

19139.3k1](/packages/litle-payments-sdk)[alcea/cnp

PHP Validation for Personal Identification Number (Validare PHP pentru Cod Numeric Personal CNP)

1175.0k](/packages/alcea-cnp)

PHPackages © 2026

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