Skip to content

Commit

Permalink
Merge pull request #4 from ofcold/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
lilianjin authored May 26, 2018
2 parents f1e3b92 + 50ad26e commit 21aecba
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 143 deletions.
105 changes: 53 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
<p align="center">
<img src="https://github.com/ofcold/identity-card/raw/2.0/id-card.svg?sanitize=true">
</p>

<p align="center">
<img src="https://img.shields.io/github/issues/ofcold/identity-card.svg">
<img src="https://img.shields.io/github/forks/ofcold/identity-card.svg">
<img src="https://img.shields.io/github/stars/ofcold/identity-card.svg">
<img src="https://img.shields.io/github/license/ofcold/identity-card.svg">
</p>

一个简单的身份证号码获取用户信息工具
<p align="center"><img src="https://github.com/ofcold/identity-card/raw/2.0/id-card.svg?sanitize=true"></p>

China (region) citizen ID card tool
------------------------
<br>
<p>
<a href="https://github.com/ofcold/identity-card/blob/2.0/README_zh_CN.md">Simplified Chinese Documentation</a>
</p>
<br>

> 中国(大陆地区)公民身份证,数据来源于国家标准GB/T 2260-2007 <a href="http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/" target="blank">(中华人民共和国行政区划代码)</a>
> China (Mainland) ID card package, the data from the national standard `GB/T 2260-2007` <a href="http://www.stats.gov.cn" target="_blank"> (People's Republic of China administrative divisions code standard).</a>
<br>
## 安装
## Installing

```bash

composer require ofcold/identity-card
```


## 说明
一个基于中华人民共和国公民身份证的组件可以获取用户信息。这个适用于任何php框架,但是只有当php版本>=7.1时才可以。
<br>
<a href="README_en.md">English Documentation</a>
## Instructions
A component based on People's Republic of China citizen ID card to obtain the user information.This works for any php framework, but only if the php version is greater than 7.1.

## 使用
## Useing

#### 验证你的身份证号码
#### Verify your Chinese ID card
```php

// 返回false 或 Ofcold\IdentityCard\IdentityCard
// Result false OR Ofcold\IdentityCard\IdentityCard instance.
$result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081');

if ( $result !== false ) {

return '您的身份证号码不正确';
return 'Your ID number is incorrect';
}

print_r($result->toArray());


```

#### 或运行测试文件
#### OR test file.
```bash
php test
```
Expand All @@ -54,9 +48,9 @@
```php

try {
$idCard = Ofcold\IdentityCard\IdentityCard::make('142701198003124054');
$idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'en');
// Use locale, Current supported zh-cn,en
// $idCard = Ofcold\IdentityCard\IdentityCard::make('142701198003124054', 'zh-cn');
// $idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'zh-cn');
$area = $idCard->getArea();
$gender = $idCard->getGender();
$birthday = $idCard->getBirthday();
Expand All @@ -69,35 +63,42 @@
}



```


#### 返回结果:
#### Results:
```json

Array
(
[area] => 山西省 运城地区 运城市
[province] => 山西省
[city] => 运城地区
[county] => 运城市
[gender] => 男
[birthday] => 1980-03-12
[age] => 38
[constellation] => 双鱼座
)

{
"area": "shan xi sheng yun cheng di qu yun cheng shi",
"province": "shan xi sheng",
"city": "yun cheng di qu",
"county": "yun cheng shi",
"gender": "Male",
"birthday": "1980-03-12",
"age": 38,
"constellation": "Pisces"
}
```


## Api
- getArea():string `获取地区`
- getConstellation():string `获取星座`
- getAge():int `获取年龄`
- getBirthday(string $foramt = 'Y-m-d'):string `获取生日`
- getGender():string `获取性别`
- getCounty():string|null `获取县城`
- getCity():string|null `获取城市`
- getProvince():string|null `获取省`
- toArray():array `全部信息`
- toJson(int $option):string `全部信息`
### Api
- getArea() : string `Get Area`
- getConstellation() : string `Get constellation`
- getAge() : int `Get age`
- getBirthday(string $foramt = 'Y-m-d') : string `Get birthday`
- getGender() : string `Get gender`
- getCounty() : string|null `Get county`
- getCity() : string|null `Get city`
- getProvince() : string|null `Get province`
- toArray() : array `Get all information.`
- toJson(int $option) : string `Json format all information`
- __get() : mixed
- __toString() : toJson


## CHANGELOG
V2.0.0
* Added [#2](https://github.com/ofcold/identity-card/pull/2) __get()
* Added [#2](https://github.com/ofcold/identity-card/pull/2) __toString()
* Modifed [#2](https://github.com/ofcold/identity-card/pull/2) static make() Method returns the current object or boolean type
* Removed [#2](https://github.com/ofcold/identity-card/pull/2) Construction method exception verification
91 changes: 0 additions & 91 deletions README_en.md

This file was deleted.

111 changes: 111 additions & 0 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<p align="center">
<img src="https://github.com/ofcold/identity-card/raw/2.0/id-card.svg?sanitize=true">
</p>

<p align="center">
<img src="https://img.shields.io/github/issues/ofcold/identity-card.svg">
<img src="https://img.shields.io/github/forks/ofcold/identity-card.svg">
<img src="https://img.shields.io/github/stars/ofcold/identity-card.svg">
<img src="https://img.shields.io/github/license/ofcold/identity-card.svg">
</p>

一个简单的身份证号码获取用户信息工具
------------------------
<br>
<p>
<a href="https://github.com/ofcold/identity-card/blob/2.0/README.md">English Documentation</a>
</p>
<br>

> 中国(大陆地区)公民身份证,数据来源于国家标准GB/T 2260-2007 <a href="http://www.stats.gov.cn" target="_blank">(中华人民共和国行政区划代码)</a>
<br>
## 安装

```bash

composer require ofcold/identity-card
```


## 说明
一个基于中华人民共和国公民身份证的组件可以获取用户信息。这个适用于任何php框架,但是只有当php版本>=7.1时才可以。

## 使用

#### 验证你的身份证号码
```php

// 返回false 或 Ofcold\IdentityCard\IdentityCard
$result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081');

if ( $result !== false ) {

return '您的身份证号码不正确';
}

print_r($result->toArray());

```

#### 或运行测试文件
```bash
php test
```


```php

try {
$idCard = Ofcold\IdentityCard\IdentityCard::make('142701198003124054');
// Use locale, Current supported zh-cn,en
// $idCard = Ofcold\IdentityCard\IdentityCard::make('142701198003124054', 'zh-cn');
$area = $idCard->getArea();
$gender = $idCard->getGender();
$birthday = $idCard->getBirthday();
$age = $idCard->getAge();
$constellation = $idCard->getConstellation();
}
catch (\Exception $e)
{
$e->getMessage();
}


```


#### 返回结果:
```json
{
"area": "山西省 运城地区 运城市",
"province": "山西省",
"city": "运城地区",
"county": "运城市",
"gender": "",
"birthday": "1980-03-12",
"age": 38,
"constellation": "双鱼座"
}

```


## Api
- getArea():string `获取地区`
- getConstellation():string `获取星座`
- getAge():int `获取年龄`
- getBirthday(string $foramt = 'Y-m-d'):string `获取生日`
- getGender():string `获取性别`
- getCounty():string|null `获取县城`
- getCity():string|null `获取城市`
- getProvince():string|null `获取省`
- toArray():array `全部信息`
- toJson(int $option):string `全部信息`

## 修改历史
V2.0.0
* 新增 [#2](https://github.com/ofcold/identity-card/pull/2) __get()
* 新增 [#2](https://github.com/ofcold/identity-card/pull/2) __toString()
* 修改 [#2](https://github.com/ofcold/identity-card/pull/2) static make() 方法返回当前对象或者boolean类型
* 移除 [#2](https://github.com/ofcold/identity-card/pull/2) 构造方法异常验证

0 comments on commit 21aecba

Please sign in to comment.