hkid.go   A
last analyzed

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
cc 4
eloc 11
dl 0
loc 24
ccs 8
cts 8
cp 1
crap 4
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hkid.CheckPart 0 3 1
A hkid.CheckString 0 12 3
1
//package hkid to check HKID Card No.
2
package hkid
3
4
// CheckString : Check HKID Format eg. CA182361(1).
5
func CheckString(string string) *result {
6 1
	hkid, e := validatePatten(string)
7
	//if errors.Is(e, newPatterNotMatchError()) {
8 1
	if e != nil {
9 1
		return newHkidResultWithValid(newHkidNil(), false)
10
	}
11
12 1
	if getRemainder(hkid) == hkid.part3 {
13 1
		return newHkidResultWithValid(hkid, true)
14
	}
15
16 1
	return newHkidResultWithValid(hkid, false)
17
}
18
19
// CheckPart : check HKID Format eg. CA182361(1).
20
// part1 = "CA"
21
// part2 = "182361"
22
// part3 = "1"
23
func CheckPart(part1 string, part2 string, part3 string) *result {
24 1
	hkid := newHkid(part1, part2, part3)
25 1
	return CheckString(hkid.Format())
26
}
27