2017 © Pedro Peláez
 

library cnp

PHP Validation for Romanian Social Security Number (Validare PHP pentru CNP)

image

alcea/cnp

PHP Validation for Romanian Social Security Number (Validare PHP pentru CNP)

  • Tuesday, March 20, 2018
  • by nicualcea
  • Repository
  • 0 Watchers
  • 3 Stars
  • 290 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

Build Status Latest Stable Version Total Downloads License, (*1)

CNP

Validation for Romanian Social Security Number (Validare CNP)., (*2)

From version 3.0 need PHP >= 7.4 From version 2.0 was added possibility to extract some data from a valid CNP (see example below)., (*3)

How to install?

1. use composer

composer require alcea/cnp

2. or, edit require section from composer.json and run composer update

"alcea/cnp": "^3.0"

3. if need PHP < 7.4 use

"alcea/cnp": "2.1.6"

How to use?

<?php
// require __DIR__ . '\vendor\autoload.php';
use alcea\cnp\Cnp;

$cnpToBeValidated = '5110102441483';

$cnp = new Cnp($cnpToBeValidated);
if ($cnp->isValid()) {
    // extract information from CNP
    echo "CNP {$cnpToBeValidated} - is valid" . PHP_EOL;
    echo "Birth Date: {$cnp->getBirthDateFromCNP('Y/m/d')}" . PHP_EOL;
    echo "Birth Place: {$cnp->getBirthCountyFromCNP()}" . PHP_EOL;
    echo "Gender: {$cnp->getGenderFromCNP('male', 'female')}" . PHP_EOL;
    echo "Serial: {$cnp->getSerialNumberFromCNP()}" . PHP_EOL; 
    echo "Person is " . ($cnp->isPersonMajor() ? '' : 'not' ) . ' major' . PHP_EOL;
    echo "Person have an Identity Card " . ($cnp->hasIdentityCard() ? 'YES' : 'NO' );
} else {
    echo "CNP {$cnpToBeValidated} is invalid" . PHP_EOL;
}

// or call static

echo "CNP {$cnpToBeValidated} is " . Cnp::validate($cnpToBeValidated) ? 'valid' : 'invalid';

How to run tests?

## Open an terminal and run commands:
git clone https://github.com/alceanicu/cnp.git
cd cnp
composer install
./vendor/bin/phpunit --bootstrap ./vendor/autoload.php --testdox

QA Tools

License

This package is licensed under the MIT license., (*4)

The Versions

20/03 2018

dev-master

9999999-dev https://github.com/alceanicu/cnp

PHP Validation for Romanian Social Security Number (Validare PHP pentru CNP)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Niku Alcea

php validare cnp

08/03 2018

v2.1.1

2.1.1.0 https://github.com/alceanicu/cnp

PHP Validation for Romanian Social Security Number (Validare PHP pentru CNP)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Niku Alcea

php validare cnp

19/07 2017

v2.1

2.1.0.0 https://github.com/alceanicu/cnp

PHP Validation for Romanian Social Security Number (Validare PHP pentru CNP)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Niku Alcea

php validare cnp

22/12 2016

v2.0

2.0.0.0 https://github.com/alceanicu/cnp

PHP Validation for Romanian Social Security Number (Validare PHP pentru CNP)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Niku Alcea

cnp

09/12 2016

v1.1

1.1.0.0

PHP - Validation for Romanian Social Security Number (Validare CNP)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Alcea Nicolae

09/12 2016

v1.0

1.0.0.0

PHP - Validation for Romanian Social Security Number (Validare CNP)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Alcea Nicolae