Total Complexity | 7 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | class BinModel implements \JsonSerializable |
||
8 | { |
||
9 | /** |
||
10 | * Bin码 |
||
11 | * @var string |
||
12 | */ |
||
13 | public string $bin; |
||
14 | |||
15 | /** |
||
16 | * 卡号长度 |
||
17 | * @var int |
||
18 | */ |
||
19 | public int $length = 0; |
||
20 | |||
21 | /** |
||
22 | * 卡类型 |
||
23 | * @var string<'DC','PC','CC','SCC'> |
||
24 | */ |
||
25 | public string $type = 'DC'; |
||
26 | |||
27 | public function __construct(string $bin, string $type, int $length) |
||
32 | } |
||
33 | |||
34 | public function toArray(): array |
||
35 | { |
||
36 | return [ |
||
37 | 'bin' => $this->bin, |
||
38 | 'length' => $this->length, |
||
39 | 'type' => $this->type |
||
40 | ]; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * 检查有效性 |
||
45 | * @param string $card_number |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function isValid(string $card_number): bool |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * jsonSerialize |
||
61 | * @return array<array<int|string|null>|string|null> |
||
62 | */ |
||
63 | public function jsonSerialize() |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * __toString |
||
70 | * @return string |
||
71 | */ |
||
72 | public function __toString(): string |
||
75 | } |
||
76 | } |