Skip to content

Commit 06c3ad1

Browse files
author
xiaolong
committed
First commit
0 parents  commit 06c3ad1

File tree

11 files changed

+4092
-0
lines changed

11 files changed

+4092
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea/
2+
/vendor/
3+
/composer.lock

.scrutinizer.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
build:
2+
nodes:
3+
analysis:
4+
project_setup:
5+
override:
6+
- 'true'
7+
tests:
8+
override:
9+
- php-scrutinizer-run
10+
-
11+
command: phpcs-run ./src
12+
use_website_config: false
13+
tests: true
14+
filter:
15+
excluded_paths:
16+
- 'tests/*'
17+
- 'data/*'
18+
checks:
19+
php: true
20+
coding_style:
21+
php: { }

.styleci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
preset: recommended
2+
risky: true
3+
finder:
4+
exclude:
5+
- data
6+
name: "*.php"

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: php
2+
3+
php:
4+
- '5.6'
5+
- '7.0'
6+
7+
matrix:
8+
fast_finish: true
9+
allow_failures:
10+
- php: hhvm
11+
12+
sudo: false
13+
14+
install: travis_retry composer install --no-interaction --prefer-source
15+
16+
script: vendor/bin/phpunit --verbose -c phpunit.xml

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 金小龙(jxlwqq)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# IdValidator.php
2+
3+
中国大陆个人身份证号码验证工具(PHP Composer 版)支持 15 位与 18 位身份证号。基于 [JavaScript 版本](https://github.com/mc-zone/IDValidator)
4+
5+
Chinese Mainland Personal ID Card Validation.
6+
7+
## 安装
8+
9+
```bash
10+
composer require "jxlwqq/id-validator"
11+
```
12+
13+
## 使用
14+
15+
### 验证身份证号合法性
16+
17+
验证身份证号是否合法,合法返回 true,不合法返回 false:
18+
19+
```php
20+
use Jxlwqq\IdValidator\IdValidator;
21+
22+
$idValidator = new IdValidator();
23+
$idValidator->isValid('440308199901101512');
24+
```
25+
26+
### 获取身份证号信息
27+
28+
当身份证号合法时,返回分析信息(地区、出生日期、性别、校验位),不合法返回 false:
29+
```php
30+
use Jxlwqq\IdValidator\IdValidator;
31+
32+
$idValidator = new IdValidator();
33+
$idValidator->getInfo('440308199901101512');
34+
```
35+
36+
### 生成可通过校验的假数据
37+
伪造符合校验的身份证:
38+
39+
```php
40+
use Jxlwqq\IdValidator\IdValidator;
41+
42+
$idValidator = new IdValidator();
43+
$idValidator->fakeId(); // 默认 生成 18 位
44+
$idValidator->fakeId(true); // 生成 15 位
45+
```
46+
47+
## 参考资料
48+
GB 11643-1999 公民身份证号码
49+
50+
GB 2260-1995 中华人民共和国行政区划代码
51+
52+
## License
53+
MIT
54+
55+

composer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "jxlwqq/id-validator",
3+
"description": "Chinese Mainland Personal ID Card Validation",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "jxlwqq",
9+
"email": "jxlwqq@gmail.com",
10+
"homepage": "https://jxlwqq.github.io"
11+
12+
}
13+
],
14+
"require": {
15+
"php": ">=5.6.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Jxlwqq\\IdValidator\\": "src/"
20+
}
21+
},
22+
"require-dev": {
23+
"phpunit/phpunit": "^5.6"
24+
}
25+
}

0 commit comments

Comments
 (0)