2017 © Pedro Peláez
 

yii2-extension yii2-kz-personalid

image

alexeevdv/yii2-kz-personalid

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 14 % Grown

The README.md

yii2-kz-personalid

Build Status codecov PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2, (*1)

Yii2 extension to deal with Kazakhstan personal identification number, (*2)

It contains: - Both server-side and client-side validators - Helper to fetch data from identification number, (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

$ php composer.phar require alexeevdv/yii2-kz-personalid "~1.0"

or add, (*6)

"alexeevdv/yii2-kz-personalid": "~1.0"

to the require section of your composer.json file., (*7)

Usage

Validation

As standalone validator

use alexeevdv\kz\PersonalidValidator;

//...
$validator = new PersonalidValidator;
$result = $validator->validateValue('123456789012');
//...

In model

use alexeevdv\kz\PersonalidValidator;

public function rules()
{
    //...
    ['personalid', PersonalidValidator::class, 'message' => 'Wrong personalid value!'],
    //...
}

Helper

use alexeevdv\kz\PersonalidHelper;

$personalid = '850407301166';

/** @var \DateTime $birtdate = 1985-04-07 */  
$birtdate = PersonalidHelper::getBirthDate($personalid);

/** @var int $sex = PersonalidHelper::SEX_MALE */
$sex = PersonalidHelper::getSex($personalid);

/** @var string $serialNumber = 0116 */
$serialNumber = PersonalidHelper::getSerialNumber($personalid);

The Versions

21/02 2018
18/02 2018
17/06 2017
17/06 2017
17/06 2017
17/06 2017
17/06 2017