File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 3838 "require-dev" : {
3939 "phpunit/phpunit" : " ^6.0||^7.0" ,
4040 "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"
4243 },
4344 "scripts" : {
4445 "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
7979 */
8080 public function calcChecksum (NumberInterface $ number ): int
8181 {
82- $ nDigits = strlen ($ number ->getNumber ());
82+ $ num = $ number ->getNumber ();
83+ $ nDigits = strlen ($ num );
8384 // Need to account for check digit
8485 $ parity = ($ nDigits + 1 ) % 2 ;
8586 $ checksum = 0 ;
8687
8788 for ($ i = 0 ; $ i < $ nDigits ; $ i ++) {
88- $ digit = (int ) $ number -> getNumber () [$ i ];
89+ $ digit = (int ) $ num [$ i ];
8990
9091 // Every other digit, starting from the rightmost,
9192 // shall be doubled.
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ public function provideCalcChecksum_success()
9595 {
9696 return [
9797 "Valid checksum " => [new Number (3199723370002 ), 50 ],
98+ "Checksum mod 10 is 0 " => [new Number (31997 ), 30 ],
9899 ];
99100 }
100101
@@ -112,6 +113,7 @@ public function provideCalcCheckDigit_success()
112113 "Valid number " => [new Number (12345 ), 5 ],
113114 "Swedish company organization ID " => [new Number (559114884 ), 5 ],
114115 "Swedish organization number " => [new Number (640319261 ), 7 ],
116+ "Checksum mod 10 is 0 " => [new Number (31997 ), 0 ],
115117 ];
116118 }
117119}
You can’t perform that action at this time.
0 commit comments