diff --git a/README.md b/README.md index cc286a8..84c915c 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,16 @@ -

- -

- -

- - - - -

- -一个简单的身份证号码获取用户信息工具 +

+ +China (region) citizen ID card tool ------------------------ +
+

+ Simplified Chinese Documentation +

+
-> 中国(大陆地区)公民身份证,数据来源于国家标准GB/T 2260-2007 (中华人民共和国行政区划代码) +> China (Mainland) ID card package, the data from the national standard `GB/T 2260-2007` (People's Republic of China administrative divisions code standard). -
-## 安装 +## Installing ```bash @@ -23,29 +18,28 @@ ``` -## 说明 -一个基于中华人民共和国公民身份证的组件可以获取用户信息。这个适用于任何php框架,但是只有当php版本>=7.1时才可以。 -
-English Documentation +## 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 ``` @@ -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(); @@ -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 diff --git a/README_en.md b/README_en.md deleted file mode 100644 index 22c21b7..0000000 --- a/README_en.md +++ /dev/null @@ -1,91 +0,0 @@ -

- -China (region) citizen ID card tool ------------------------- - -> China (Mainland) ID card package, the data from the national standard `GB/T 2260-2007` (People's Republic of China administrative divisions code standard). - -## Installing - -```bash - - composer require ofcold/identity-card -``` - - -## 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 - - // Result false OR Ofcold\IdentityCard\IdentityCard instance. - $result = Ofcold\IdentityCard\IdentityCard::make('32010619831029081'); - - if ( $result !== false ) { - - return 'Your ID number is incorrect'; - } - - print_r($result->toArray()); - - -``` - -#### OR test file. -```bash - php test -``` - - -```php - - try { - $idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'en'); - // Use locale, Current supported zh-cn,en - // $idCard = Ofcold\IdentityCard\IdentityCard::make('320106198310290811', 'zh-cn'); - $area = $idCard->getArea(); - $gender = $idCard->getGender(); - $birthday = $idCard->getBirthday(); - $age = $idCard->getAge(); - $constellation = $idCard->getConstellation(); - } - catch (\Exception $e) - { - $e->getMessage(); - } - - - -``` - - -#### Results: -```json - -Array -( - [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 `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` diff --git a/README_zh_CN.md b/README_zh_CN.md new file mode 100644 index 0000000..a27d071 --- /dev/null +++ b/README_zh_CN.md @@ -0,0 +1,111 @@ +

+ +

+ +

+ + + + +

+ +一个简单的身份证号码获取用户信息工具 +------------------------ +
+

+ English Documentation +

+
+ +> 中国(大陆地区)公民身份证,数据来源于国家标准GB/T 2260-2007 (中华人民共和国行政区划代码) + +
+## 安装 + +```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) 构造方法异常验证