dakalab/card-parser

Card parser for ID number and Bank account of China

v1.6.0 2020-03-12 15:57 UTC

This package is auto-updated.

Last update: 2024-11-13 02:13:09 UTC


README

Card parser for ID number and Bank account of China

Build Status codecov Latest Stable Version Total Downloads License

Install

composer require dakalab/card-parser

require php >= 7

ID Card

Usage

use Dakalab\CardParser\IDCard;

$no = 'the-id-number';
$lang = 'zh'; // optional, default is zh

$idCard = new IDCard($no);
$info = $idCard->info; // equal to `$info = $idCard->info();`
print_r($info);
$age = $idCard->age; // equal to `$age = $idCard->age();`
echo $age . PHP_EOL;

Result

The result info will be in below formats:

  1. for valid ID number:
Array
(
    [valid] => true
    [gender] => M|F
    [birthday] => yyyy-mm-dd
    [province] => string
    [city] => string
    [county] => string
    [address] => string
    [age] => integer
    [constellation] => string
    [version] => 1|2
)
  1. for invalid ID number:
Array
(
    [valid] => false
    [error] => "error message"
)

Generate random ID number

echo IDCard::generate();

Bank Card

Usage

use Dakalab\CardParser\BankCard;

$no = 'the-bank-account';
$lang = 'zh'; // optional, default is zh

$bankCard = new BankCard($no, $lang);
print_r($bankCard->info);

Result

The result info will be in below formats:

  1. for valid bank account:
Array
(
    [valid] => true
    [bankCode] => string
    [bankName] => string
    [cardType] => string
    [cardTypeName] => string
    [icon] => string
)
  1. for invalid bank account:
Array
(
    [valid] => false
)