File tree 3 files changed +7
-3
lines changed
3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 38
38
"require-dev" : {
39
39
"phpunit/phpunit" : " ^6.0||^7.0" ,
40
40
"friendsofphp/php-cs-fixer" : " ^2.15" ,
41
- "php-coveralls/php-coveralls" : " ^2.1"
41
+ "php-coveralls/php-coveralls" : " ^2.1" ,
42
+ "symfony/yaml" : " ^5.0"
42
43
},
43
44
"scripts" : {
44
45
"lint" : " php-cs-fixer fix" ,
Original file line number Diff line number Diff line change @@ -79,13 +79,14 @@ public function calcCheckDigit(NumberInterface $number): int
79
79
*/
80
80
public function calcChecksum (NumberInterface $ number ): int
81
81
{
82
- $ nDigits = strlen ($ number ->getNumber ());
82
+ $ num = $ number ->getNumber ();
83
+ $ nDigits = strlen ($ num );
83
84
// Need to account for check digit
84
85
$ parity = ($ nDigits + 1 ) % 2 ;
85
86
$ checksum = 0 ;
86
87
87
88
for ($ i = 0 ; $ i < $ nDigits ; $ i ++) {
88
- $ digit = (int ) $ number -> getNumber () [$ i ];
89
+ $ digit = (int ) $ num [$ i ];
89
90
90
91
// Every other digit, starting from the rightmost,
91
92
// shall be doubled.
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ public function provideCalcChecksum_success()
95
95
{
96
96
return [
97
97
"Valid checksum " => [new Number (3199723370002 ), 50 ],
98
+ "Checksum mod 10 is 0 " => [new Number (31997 ), 30 ],
98
99
];
99
100
}
100
101
@@ -112,6 +113,7 @@ public function provideCalcCheckDigit_success()
112
113
"Valid number " => [new Number (12345 ), 5 ],
113
114
"Swedish company organization ID " => [new Number (559114884 ), 5 ],
114
115
"Swedish organization number " => [new Number (640319261 ), 7 ],
116
+ "Checksum mod 10 is 0 " => [new Number (31997 ), 0 ],
115
117
];
116
118
}
117
119
}
You can’t perform that action at this time.
0 commit comments