ybelenko / ogrn
Tiny library for validating OGRN and OGRNIP business identifiers in Russia.
Requires
- php: ^7.0 || ^8.0
- ext-gmp: *
Requires (Dev)
- phpmd/phpmd: ^2.11
- phpunit/phpunit: ^8.0 || ^9.0
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2025-01-22 03:06:55 UTC
README
Tiny PHP library for validating OGRN(ОГРН) and OGRNIP(ОГРНИП) business identifiers in Russia. It just verifies number length and last control digit, so if identifier passes validation it doesn't mean that it exists in a real world. If you need to check that OGRN or OGRNIP exists visit http://egrul.nalog.ru.
Installation
It's recommended that you use Composer to install.
$ composer require ybelenko/ogrn
Usage
require_once __DIR__ . '/vendor/autoload.php'; use Ybelenko\Ogrn\Ogrn; use Ybelenko\Ogrn\Ogrnip; // when you need to validate OGRN number $isValid = Ogrn::validate("1127746509780");// returns true if identifier is valid // when you need to validate OGRNIP number $isValid = Ogrnip::validate("304500116000157");// returns true if identifier is valid
While 32 bit systems have a maximum signed integer range of -2147483648 to 2147483647 you always should store OGRN and OGRNIP identifiers as string.
$ogrn = 1127746509780; // is bad echo $ogrn; // 2147483647 $ogrn = '1127746509780'; // is good echo $ogrn; // 1127746509780
Tests
To execute the test suite, you'll need to clone current repo and install it with dev dependencies:
$ git clone https://github.com/ybelenko/ogrn $ cd ogrn $ composer install $ composer test