avto-dev/identity-laravel is a Laravel package for identity for laravel.
It currently has 3 GitHub stars and 30.207 downloads on Packagist (latest version v6.0.0).
Install it with composer require avto-dev/identity-laravel.
Discover more Laravel packages by avto-dev
or browse all Laravel packages to compare alternatives.
Last updated
IDEntity (identification entities) is objects with implemented methods of validation, normalization, and optional automatic type determination.
Require this package with composer using the next command:
$ composer require avto-dev/identity-laravel "^6.0"
Installed
composeris required. To install composer, please click here.
Please note that you need to fix the major version of the package.
After that you can "publish" configuration file (./config/identity.php) using next command:
$ ./artisan vendor:publish --provider="AvtoDev\IDEntity\ServiceProvider"
Below you can find some usage examples.
Type detection:
use AvtoDev\IDEntity\IDEntity;
IDEntity::is('JF1SJ5LC5DG048667', IDEntity::ID_TYPE_VIN); // true
IDEntity::is('A123AA177', IDEntity::ID_TYPE_VIN); // false
IDEntity::is('JF1SJ5LC5DG048667', IDEntity::ID_TYPE_GRZ); // false
IDEntity::is('A123AA177', IDEntity::ID_TYPE_GRZ); // true
IDEntity::is('14:36:102034:2256', IDEntity::ID_TYPE_CADASTRAL_NUMBER); // true
IDEntity::is('JF1SJ5LC5DG048667', IDEntity::ID_TYPE_CADASTRAL_NUMBER); // false
$valid_vin = IDEntity::make('JF1SJ5LC5DG048667', IDEntity::ID_TYPE_VIN);
$valid_vin->isValid(); // true
$invalid_vin = IDEntity::make('SOME INVALID', IDEntity::ID_TYPE_VIN);
$invalid_vin->isValid(); // false
Entities creation:
use AvtoDev\IDEntity\IDEntity;
use AvtoDev\IDEntity\Types\IDEntityCadastralNumber;
$vin = IDEntity::make('JF1SJ5LC5DG048667');
$vin->getType(); // 'VIN'
$vin->getValue(); // 'JF1SJ5LC5DG048667'
$vin->isValid(); // true
\get_class($vin); // 'AvtoDev\IDEntity\Types\IDEntityVin'
$cadastral_number = new IDEntityCadastralNumber('10:01:0030104:691');
$cadastral_number->getType(); // 'CADNUM'
$cadastral_number->isValid(); // true
Some typed entity classes contains a lot of additional methods for a working with passed value.
Value normalization:
use AvtoDev\IDEntity\IDEntity;
use AvtoDev\IDEntity\Types\IDEntityVin;
$vin = new IDEntityVin(' jf1SJ5LC5DG048 667');
$vin->getValue(); // 'JF1SJ5LC5DG048667'
IDEntity::make(' a123аY777', IDEntity::ID_TYPE_GRZ)->getValue(); // 'А123АУ777'
Value masking:
<?php
use AvtoDev\IDEntity\Types\IDEntityVin;
$vin = IDEntityVin::make('JF1SJ5LC5DG048667');
$vin->getMaskedValue(2, 4); // JF***********8667
$vin->getMaskedValue(4, 2, '_'); // JF1S___________67
For package testing we use phpunit framework and docker-ce + docker-compose as develop environment. So, just write into your terminal after repository cloning:
$ make build
$ make latest # or 'make lowest'
$ make test
Changes log can be found here.
If you will find any package errors, please, make an issue in current repository.
This is open-sourced software licensed under the MIT License.