Fix CS in IsbnValidator and IssnValidator

This commit is contained in:
Guilliam Xavier 2021-04-13 14:44:21 +02:00 committed by Nyholm
parent 3f42c08abd
commit dc90c195e3
No known key found for this signature in database
GPG Key ID: D6332DE2B6F8FA38
2 changed files with 2 additions and 6 deletions

View File

@ -163,8 +163,7 @@ class IsbnValidator extends ConstraintValidator
} }
for ($i = 1; $i < 12; $i += 2) { for ($i = 1; $i < 12; $i += 2) {
$checkSum += $isbn[$i] $checkSum += $isbn[$i] * 3;
* 3;
} }
return 0 === $checkSum % 10 ? true : Isbn::CHECKSUM_FAILED_ERROR; return 0 === $checkSum % 10 ? true : Isbn::CHECKSUM_FAILED_ERROR;

View File

@ -114,10 +114,7 @@ class IssnValidator extends ConstraintValidator
} }
// Calculate a checksum. "X" equals 10. // Calculate a checksum. "X" equals 10.
$checkSum = 'X' === $canonical[7] $checkSum = 'X' === $canonical[7] || 'x' === $canonical[7] ? 10 : $canonical[7];
|| 'x' === $canonical[7]
? 10
: $canonical[7];
for ($i = 0; $i < 7; ++$i) { for ($i = 0; $i < 7; ++$i) {
// Multiply the first digit by 8, the second by 7, etc. // Multiply the first digit by 8, the second by 7, etc.