2017 © Pedro Peláez
 

library identity-laravel

IDEntity for Laravel

image

avto-dev/identity-laravel

IDEntity for Laravel

  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 1 Forks
  • 1 Open issues
  • 21 Versions
  • 66 % Grown

The README.md

IDEntity , (*1)

IDEntity

Version ![PHP Version][badge_php_version] Build Status ![Coverage][badge_coverage] Downloads count ![License][badge_license], (*2)

IDEntity (identification entities) is objects with implemented methods of validation, normalization, and optional automatic type determination., (*3)

Installation

Require this package with composer using the next command:, (*4)

$ composer require avto-dev/identity-laravel "^5.0"

Installed composer is required. To install composer, please click here., (*5)

Please note that you need to fix the major version of the package., (*6)

After that you can "publish" configuration file (./config/identity.php) using next command:, (*7)

$ ./artisan vendor:publish --provider="AvtoDev\IDEntity\ServiceProvider"

Usage

Below you can find some usage examples., (*8)

Type detection:, (*9)

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:, (*10)

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., (*11)

Value normalization:, (*12)

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:, (*13)

<?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:, (*14)

$ make build
$ make latest # or 'make lowest'
$ make test

Changes log

Release date ![Commits since latest release][badge_commits_since_release], (*15)

Changes log can be found here., (*16)

Support

Issues ![Issues][badge_pulls], (*17)

If you will find any package errors, please, make an issue in current repository., (*18)

License

This is open-sourced software licensed under the MIT License., (*19)

The Versions

08/02 2018
08/02 2018
06/02 2018