1 | <?php |
||
5 | class IDCard |
||
6 | { |
||
7 | /** |
||
8 | * 身份证号. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | private $id; |
||
13 | |||
14 | /** |
||
15 | * 行政区划代码 |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $areaCodes; |
||
20 | |||
21 | 16 | public function __construct(string $id) |
|
26 | |||
27 | /** |
||
28 | * 验证身份号. |
||
29 | * |
||
30 | * @return bool |
||
31 | */ |
||
32 | 9 | public function check() |
|
36 | |||
37 | /** |
||
38 | * 验证行政区划代码 |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | 10 | public function checkAreaCode() |
|
48 | |||
49 | /** |
||
50 | * 验证生日. |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | 10 | public function checkBirthday() |
|
62 | |||
63 | /** |
||
64 | * 验证校验码 |
||
65 | * |
||
66 | * @return bool |
||
67 | */ |
||
68 | 10 | public function checkCode() |
|
80 | |||
81 | /** |
||
82 | * 获取地址 |
||
83 | * |
||
84 | * @param string $separator |
||
85 | * |
||
86 | * @return bool|string |
||
87 | */ |
||
88 | 1 | public function address(string $separator = '') |
|
92 | |||
93 | /** |
||
94 | * 获取省 |
||
95 | * |
||
96 | * @return bool|mixed |
||
97 | */ |
||
98 | 2 | public function province() |
|
104 | |||
105 | /** |
||
106 | * 获取市 |
||
107 | * |
||
108 | * @return bool|mixed |
||
109 | */ |
||
110 | 2 | public function city() |
|
116 | |||
117 | /** |
||
118 | * 获取区. |
||
119 | * |
||
120 | * @return bool|mixed |
||
121 | */ |
||
122 | 2 | public function zone() |
|
128 | |||
129 | /** |
||
130 | * 获取生日. |
||
131 | * |
||
132 | * @param string $format |
||
133 | * |
||
134 | * @return bool|string |
||
135 | */ |
||
136 | 1 | public function birthday(string $format) |
|
140 | |||
141 | /** |
||
142 | * 获取年. |
||
143 | * |
||
144 | * @return int |
||
145 | */ |
||
146 | 4 | public function year() |
|
150 | |||
151 | /** |
||
152 | * 获取月. |
||
153 | * |
||
154 | * @return int |
||
155 | */ |
||
156 | 4 | public function month() |
|
160 | |||
161 | /** |
||
162 | * 获取日. |
||
163 | * |
||
164 | * @return int |
||
165 | */ |
||
166 | 4 | public function day() |
|
170 | |||
171 | /** |
||
172 | * 获取年龄. |
||
173 | * |
||
174 | * @return false|int|string |
||
175 | */ |
||
176 | 1 | public function age() |
|
200 | |||
201 | /** |
||
202 | * 获取性别. |
||
203 | * |
||
204 | * @return bool|string 身份证号未通过验证返回 false |
||
205 | */ |
||
206 | 1 | public function sex() |
|
210 | |||
211 | /** |
||
212 | * 获取星座. |
||
213 | * |
||
214 | * @return bool|mixed |
||
215 | */ |
||
216 | 1 | public function constellation() |
|
234 | |||
235 | /** |
||
236 | * 获取属相. |
||
237 | * |
||
238 | * @return bool|string |
||
239 | */ |
||
240 | 1 | public function zodiac() |
|
252 | } |
||
253 |