mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-30 12:07:32 +00:00
🛀 extract Mode
This commit is contained in:
@@ -85,4 +85,11 @@ class Mode{
|
||||
throw new QRCodeException(sprintf('invalid version number: %d', $version));
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the array of length bits for the given mode
|
||||
*/
|
||||
public static function getLengthBitsForMode(int $mode):array{
|
||||
return self::LENGTH_BITS[$mode];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ class QRData{
|
||||
|
||||
foreach($this->dataSegments as $segment){
|
||||
// data length in bits of the current segment +4 bits for each mode descriptor
|
||||
$length += ($segment->getLengthInBits() + Mode::LENGTH_BITS[$segment->getDataMode()][0] + 4);
|
||||
$length += ($segment->getLengthInBits() + Mode::getLengthBitsForMode($segment->getDataMode())[0] + 4);
|
||||
|
||||
if(!$segment instanceof ECI){
|
||||
// mode length bits margin to the next breakpoint
|
||||
|
||||
Reference in New Issue
Block a user