1 | <?php |
||
5 | class IDCard |
||
6 | { |
||
7 | /** |
||
8 | * 身份证号. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $id; |
||
13 | |||
14 | /** |
||
15 | * 行政区划代码 |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $areaCodes; |
||
20 | |||
21 | 16 | public function __construct(string $id) |
|
26 | |||
27 | /** |
||
28 | * 验证身份号. |
||
29 | * |
||
30 | * @return bool |
||
31 | */ |
||
32 | 9 | public function check() |
|
33 | { |
||
34 | 9 | return $this->checkAreaCode() && $this->checkBirthday() && $this->checkCode(); |
|
35 | } |
||
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 false|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 bool|int |
||
175 | */ |
||
176 | 1 | public function age() |
|
196 | |||
197 | /** |
||
198 | * 获取性别. |
||
199 | * |
||
200 | * @return bool|string |
||
201 | */ |
||
202 | 1 | public function sex() |
|
206 | |||
207 | /** |
||
208 | * 获取星座. |
||
209 | * |
||
210 | * @return bool|mixed |
||
211 | */ |
||
212 | 1 | public function constellation() |
|
226 | |||
227 | /** |
||
228 | * 获取属相. |
||
229 | * |
||
230 | * @return bool|string |
||
231 | */ |
||
232 | 1 | public function zodiac() |
|
239 | } |
||
240 |