avto-dev / identity-laravel
IDEntity for Laravel
Installs: 26 755
Dependents: 1
Suggesters: 1
Security: 0
Stars: 3
Watchers: 2
Forks: 11
Open Issues: 1
Requires
- php: ^8.1
- ext-json: *
- ext-mbstring: *
- avto-dev/extended-laravel-validator: ^4.0
- avto-dev/static-references-laravel: ^4.5
- danielstjules/stringy: ~3.1.0
- illuminate/config: ~10.0 || ~11.0
- illuminate/container: ~10.0 || ~11.0
- illuminate/contracts: ~10.0 || ~11.0
- illuminate/support: ~10.0 || ~11.0
Requires (Dev)
- laravel/laravel: ~10.0 || ~11.0
- phpstan/phpstan: ^1.10.66
- phpunit/phpunit: ^10.5
Suggests
- avto-dev/faker-identifiers-providers: Identifiers providers for fzaninotto/Faker package
This package is auto-updated.
Last update: 2024-12-22 08:08:51 UTC
README
IDEntity
IDEntity (identification entities) is objects with implemented methods of validation, normalization, and optional automatic type determination.
Installation
Require this package with composer using the next command:
$ composer require avto-dev/identity-laravel "^5.0"
Installed
composer
is 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"
Usage
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
Testing
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
Changes log can be found here.
Support
If you will find any package errors, please, make an issue in current repository.
License
This is open-sourced software licensed under the MIT License.