hkid.CheckPart   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
nop 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