mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-26 21:28:08 +00:00
🛀 clean-up (again)
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
namespace chillerlan\QRCode\Decoder;
|
||||
|
||||
use chillerlan\QRCode\Common\{BitBuffer, EccLevel, GenericGFPoly, GF256, Version};
|
||||
use chillerlan\QRCode\QRCodeException;
|
||||
use function array_fill, array_reverse, count;
|
||||
|
||||
/**
|
||||
@@ -167,7 +166,7 @@ final class ReedSolomonDecoder{
|
||||
* @param int $numEccCodewords number of error-correction codewords available
|
||||
*
|
||||
* @return int[]
|
||||
* @throws \chillerlan\QRCode\QRCodeException if decoding fails for any reason
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException if decoding fails for any reason
|
||||
*/
|
||||
private function decodeWords(array $received, int $numEccCodewords):array{
|
||||
$poly = new GenericGFPoly($received);
|
||||
@@ -201,7 +200,7 @@ final class ReedSolomonDecoder{
|
||||
$position = ($receivedCount - 1 - GF256::log($errorLocations[$i]));
|
||||
|
||||
if($position < 0){
|
||||
throw new QRCodeException('Bad error location');
|
||||
throw new QRCodeDecoderException('Bad error location');
|
||||
}
|
||||
|
||||
$received[$position] ^= $errorMagnitudes[$i];
|
||||
@@ -212,7 +211,7 @@ final class ReedSolomonDecoder{
|
||||
|
||||
/**
|
||||
* @return \chillerlan\QRCode\Common\GenericGFPoly[] [sigma, omega]
|
||||
* @throws \chillerlan\QRCode\QRCodeException
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
|
||||
*/
|
||||
private function runEuclideanAlgorithm(GenericGFPoly $a, GenericGFPoly $b, int $z):array{
|
||||
// Assume a's degree is >= b's
|
||||
@@ -240,14 +239,14 @@ final class ReedSolomonDecoder{
|
||||
$t = $q->multiply($tLast)->addOrSubtract($tLastLast);
|
||||
|
||||
if($r->getDegree() >= $rLast->getDegree()){
|
||||
throw new QRCodeException('Division algorithm failed to reduce polynomial?');
|
||||
throw new QRCodeDecoderException('Division algorithm failed to reduce polynomial?');
|
||||
}
|
||||
}
|
||||
|
||||
$sigmaTildeAtZero = $t->getCoefficient(0);
|
||||
|
||||
if($sigmaTildeAtZero === 0){
|
||||
throw new QRCodeException('sigmaTilde(0) was zero');
|
||||
throw new QRCodeDecoderException('sigmaTilde(0) was zero');
|
||||
}
|
||||
|
||||
$inverse = GF256::inverse($sigmaTildeAtZero);
|
||||
@@ -256,7 +255,7 @@ final class ReedSolomonDecoder{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \chillerlan\QRCode\QRCodeException
|
||||
* @throws \chillerlan\QRCode\Decoder\QRCodeDecoderException
|
||||
*/
|
||||
private function findErrorLocations(GenericGFPoly $errorLocator):array{
|
||||
// This is a direct application of Chien's search
|
||||
@@ -277,7 +276,7 @@ final class ReedSolomonDecoder{
|
||||
}
|
||||
|
||||
if($e !== $numErrors){
|
||||
throw new QRCodeException('Error locator degree does not match number of roots');
|
||||
throw new QRCodeDecoderException('Error locator degree does not match number of roots');
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user