Giter Site home page Giter Site logo

identity-laravel's Introduction

IDEntity

IDEntity

Version PHP Version Build Status Coverage Downloads count License

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

Release date Commits since latest release

Changes log can be found here.

Support

Issues Issues

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.

identity-laravel's People

Contributors

eldario avatar gunzhin avatar tarampampam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.