mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-26 15:48:11 +00:00
🚿 docblocks (WIP)
This commit is contained in:
@@ -47,6 +47,9 @@ final class Binarizer{
|
||||
|
||||
private LuminanceSource $source;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct(LuminanceSource $source){
|
||||
$this->source = $source;
|
||||
}
|
||||
@@ -154,6 +157,9 @@ final class Binarizer{
|
||||
return $this->getHistogramBlackMatrix($width, $height);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getHistogramBlackMatrix(int $width, int $height):BitMatrix{
|
||||
$matrix = new BitMatrix(max($width, $height));
|
||||
|
||||
|
||||
@@ -15,12 +15,18 @@ use chillerlan\QRCode\Common\{MaskPattern, Version};
|
||||
use InvalidArgumentException;
|
||||
use function array_fill, count;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class BitMatrix{
|
||||
|
||||
private int $dimension;
|
||||
private int $rowSize;
|
||||
private array $bits;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct(int $dimension){
|
||||
$this->dimension = $dimension;
|
||||
$this->rowSize = ((int)(($this->dimension + 0x1f) / 0x20));
|
||||
|
||||
@@ -61,6 +61,9 @@ final class BitMatrixParser{
|
||||
$this->bitMatrix->mirror();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function copyBit(int $i, int $j, int $versionBits):int{
|
||||
|
||||
$bit = $this->mirror
|
||||
@@ -335,6 +338,9 @@ final class BitMatrixParser{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function uRShift(int $a, int $b):int{
|
||||
|
||||
if($b === 0){
|
||||
@@ -344,6 +350,9 @@ final class BitMatrixParser{
|
||||
return ($a >> $b) & ~((1 << (8 * PHP_INT_SIZE - 1)) >> ($b - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static function numBitsDiffering(int $a, int $b):int{
|
||||
// a now has a 1 bit exactly where its bit differs with b's
|
||||
$a ^= $b;
|
||||
|
||||
@@ -29,6 +29,9 @@ final class DecoderResult{
|
||||
private int $structuredAppendParity;
|
||||
private int $structuredAppendSequenceNumber;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct(
|
||||
array $rawBytes,
|
||||
string $text,
|
||||
@@ -59,26 +62,44 @@ final class DecoderResult{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __toString():string{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getVersion():Version{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getEccLevel():EccLevel{
|
||||
return $this->eccLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function hasStructuredAppend():bool{
|
||||
return $this->structuredAppendParity >= 0 && $this->structuredAppendSequenceNumber >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getStructuredAppendParity():int{
|
||||
return $this->structuredAppendParity;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function getStructuredAppendSequenceNumber():int{
|
||||
return $this->structuredAppendSequenceNumber;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ final class GDLuminanceSource extends LuminanceSource{
|
||||
$this->setLuminancePixels();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function setLuminancePixels():void{
|
||||
for($j = 0; $j < $this->height; $j++){
|
||||
for($i = 0; $i < $this->width; $i++){
|
||||
|
||||
@@ -39,6 +39,9 @@ final class IMagickLuminanceSource extends LuminanceSource{
|
||||
$this->setLuminancePixels();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function setLuminancePixels():void{
|
||||
$this->imagick->setImageColorspace(Imagick::COLORSPACE_GRAY);
|
||||
$pixels = $this->imagick->exportImagePixels(1, 1, $this->width, $this->height, 'RGB', Imagick::PIXEL_CHAR);
|
||||
|
||||
@@ -29,6 +29,9 @@ abstract class LuminanceSource{
|
||||
protected int $width;
|
||||
protected int $height;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct(int $width, int $height){
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
|
||||
Reference in New Issue
Block a user