renekorss / personal-id-code-php
Estonian personal ID code validator and processor
Installs: 155 764
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.1
- php-coveralls/php-coveralls: ^2.1
- phpdocumentor/phpdocumentor: ~3.0.0
- phpmd/phpmd: ^2.9
- phpunit/phpunit: ^9.4
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-10-29 00:54:20 UTC
README
Personal ID code
Estonian personal ID code validator and processor
Install
composer require renekorss/personal-id-code-php
Usage
use RKD\PersonalIdCode\PersonalIdCode; $id = new PersonalIdCode('39002102761'); // These results are examples as of 2018-11-26 echo $id->getGender(); // male $datetime = $id->getBirthDate(); // Datetime object echo $datetime->format('Y-m-d'); // 1990-02-10 echo $id->getAge(); // 28 echo $id->getBirthCentury(); // 1900 // Birth year in different formats echo $id->getBirthYear(); // 1990 echo $id->getBirthYear('y'); // 90 // Birth month in different formats echo $id->getBirthMonth(); // 02 echo $id->getBirthMonth('M'); // Feb echo $id->getBirthMonth('F'); // February // Birth day in different formats echo $id->getBirthDay(); // 10 echo $id->getBirthDay('D'); // Sat echo $id->getBirthDay('l'); // Saturday // Presumable hospital where person was born echo $id->getHospital(); // Maarjamõisa Kliinikum (Tartu), Jõgeva Haigla // Check validity if ($id->validate()) { echo 'Valid personal ID code'; } else { echo 'Invalid personal ID code'; }
Tasks
composer build
- build by running tests and all code checkscomposer tests
- run testscomposer format
- format code against standardscomposer docs
- build API documentationcomposer phpmd
- run PHP Mess Detectorcomposer phpcs
- run PHP CodeSniffer
License
Licensed under MIT