This commit is contained in:
smiley
2023-03-08 22:39:07 +01:00
parent 29e8812b77
commit 4234541d45
12 changed files with 28 additions and 35 deletions
+2 -1
View File
@@ -3,9 +3,10 @@
* Class ECICharset
*
* @created 21.01.2021
* @author ZXing Authors
* @author smiley <smiley@chillerlan.net>
* @copyright 2021 smiley
* @license MIT
* @license Apache-2.0
*/
namespace chillerlan\QRCode\Common;
+3
View File
@@ -143,6 +143,9 @@ final class EccLevel{
/**
* @param int $eccLevel containing the two bits encoding a QR Code's error correction level
*
* @todo: accept string values (PHP8+)
* @see https://github.com/chillerlan/php-qrcode/discussions/160
*
* @throws \chillerlan\QRCode\QRCodeException
*/
public function __construct(int $eccLevel){
+1 -1
View File
@@ -14,7 +14,7 @@ use chillerlan\QRCode\Data\{AlphaNum, Byte, Hanzi, Kanji, Number};
use chillerlan\QRCode\QRCodeException;
/**
* ISO 18004:2006, 6.4.1, Tables 2 and 3
* Data mode information - ISO 18004:2006, 6.4.1, Tables 2 and 3
*/
final class Mode{
+1 -1
View File
@@ -15,7 +15,7 @@ use chillerlan\QRCode\QRCodeException;
use function array_fill, array_reverse, count;
/**
* Implements Reed-Solomon decoding, as the name implies.
* Implements Reed-Solomon decoding
*
* The algorithm will not be explained here, but the following references were helpful
* in creating this implementation:
+1 -1
View File
@@ -13,7 +13,7 @@ namespace chillerlan\QRCode\Common;
use function array_fill, array_merge, count, max;
/**
* ISO/IEC 18004:2000 Section 8.5 ff
* Reed-Solomon encoding - ISO/IEC 18004:2000 Section 8.5 ff
*
* @see http://www.thonky.com/qr-code-tutorial/error-correction-coding
*/
+1 -1
View File
@@ -15,7 +15,7 @@ use chillerlan\QRCode\Common\{BitBuffer, Mode};
use function chr, ord;
/**
* Byte mode, ISO-8859-1 or UTF-8
* 8-bit Byte mode, ISO-8859-1 or UTF-8
*
* ISO/IEC 18004:2000 Section 8.3.4
* ISO/IEC 18004:2000 Section 8.4.4
+1 -1
View File
@@ -96,7 +96,7 @@ final class QRData{
* Sets a BitBuffer object
*
* This can be used instead of setData(), however, the version auto-detection is not available in this case.
* The version needs match the length bits range for the data mode the data has been encoded with,
* The version needs to match the length bits range for the data mode the data has been encoded with,
* additionally the bit array needs to contain enough pad bits.
*
* @throws \chillerlan\QRCode\Data\QRCodeDataException
+1 -1
View File
@@ -14,7 +14,7 @@ use chillerlan\QRCode\Common\{BitBuffer, EccLevel, MaskPattern, ReedSolomonEncod
use function array_fill, count, floor, range;
/**
* Holds a numerical representation of the final QR Code;
* Holds an array representation of the final QR Code that contains numerical values for later output modifications;
* maps the ECC coded binary data and applies the mask pattern
*
* @see http://www.thonky.com/qr-code-tutorial/format-version-information
+1 -1
View File
@@ -61,7 +61,7 @@ final class BitMatrix extends QRMatrix{
0x2BED, // 0010101111101101
];
private const FORMAT_INFO_MASK_QR = 0x5412;
private const FORMAT_INFO_MASK_QR = 0x5412; // 0101010000010010
private bool $mirror = false;
+1 -4
View File
@@ -18,10 +18,7 @@ use function array_slice, array_splice, file_exists, is_file, is_readable, realp
/**
* The purpose of this class hierarchy is to abstract different bitmap implementations across
* platforms into a standard interface for requesting greyscale luminance values. The interface
* only provides immutable methods; therefore crop and rotation create copies. This is to ensure
* that one Reader does not modify the original luminance source and leave it in an unknown state
* for other Readers in the chain.
* platforms into a standard interface for requesting greyscale luminance values.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
+12 -23
View File
@@ -164,7 +164,7 @@ class QRCode{
protected SettingsContainerInterface $options;
/**
* A collection of one or more data segments of [classname, data] to write
* A collection of one or more data segments of QRDataModeInterface instances to write
*
* @var \chillerlan\QRCode\Data\QRDataModeInterface[]
*/
@@ -338,8 +338,10 @@ class QRCode{
* ISO/IEC 18004:2000 8.3.6 - Mixing modes
* ISO/IEC 18004:2000 Annex H - Optimisation of bit stream length
*/
public function addSegment(QRDataModeInterface $segment):void{
public function addSegment(QRDataModeInterface $segment):self{
$this->dataSegments[] = $segment;
return $this;
}
/**
@@ -359,9 +361,7 @@ class QRCode{
* ISO/IEC 18004:2000 8.3.2 - Numeric Mode
*/
public function addNumericSegment(string $data):self{
$this->addSegment(new Number($data));
return $this;
return $this->addSegment(new Number($data));
}
/**
@@ -370,9 +370,7 @@ class QRCode{
* ISO/IEC 18004:2000 8.3.3 - Alphanumeric Mode
*/
public function addAlphaNumSegment(string $data):self{
$this->addSegment(new AlphaNum($data));
return $this;
return $this->addSegment(new AlphaNum($data));
}
/**
@@ -381,9 +379,7 @@ class QRCode{
* ISO/IEC 18004:2000 8.3.5 - Kanji Mode
*/
public function addKanjiSegment(string $data):self{
$this->addSegment(new Kanji($data));
return $this;
return $this->addSegment(new Kanji($data));
}
/**
@@ -392,9 +388,7 @@ class QRCode{
* GBT18284-2000 Hanzi Mode
*/
public function addHanziSegment(string $data):self{
$this->addSegment(new Hanzi($data));
return $this;
return $this->addSegment(new Hanzi($data));
}
/**
@@ -403,9 +397,7 @@ class QRCode{
* ISO/IEC 18004:2000 8.3.4 - 8-bit Byte Mode
*/
public function addByteSegment(string $data):self{
$this->addSegment(new Byte($data));
return $this;
return $this->addSegment(new Byte($data));
}
/**
@@ -416,9 +408,7 @@ class QRCode{
* ISO/IEC 18004:2000 8.3.1 - Extended Channel Interpretation (ECI) Mode
*/
public function addEciDesignator(int $encoding):self{
$this->addSegment(new ECI($encoding));
return $this;
return $this->addSegment(new ECI($encoding));
}
/**
@@ -438,12 +428,11 @@ class QRCode{
// convert the string to the given charset
if($eciCharsetName !== null){
$data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding());
$this
return $this
->addEciDesignator($eciCharset->getID())
->addByteSegment($data)
;
return $this;
}
throw new QRCodeException('unable to add ECI segment');
+3
View File
@@ -49,6 +49,9 @@ trait QROptionsTrait{
* - M => 15%
* - Q => 25%
* - H => 30%
*
* @todo: accept string values (PHP8+)
* @see https://github.com/chillerlan/php-qrcode/discussions/160
*/
protected int $eccLevel = EccLevel::L;