Skip to content

Commit b30c369

Browse files
committed
:octocat: make QRData::estimateTotalBitLength() and QRData::getMinimumVersion() public
1 parent 5fe305b commit b30c369

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Data/QRData.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public function writeMatrix(MaskPattern $maskPattern):QRMatrix{
134134
*
135135
* @throws \chillerlan\QRCode\Data\QRCodeDataException
136136
*/
137-
private function estimateTotalBitLength():int{
138-
$length = 0;
137+
public function estimateTotalBitLength():int{
138+
$length = 4; // 4 bits for the terminator
139139
$margin = 0;
140140

141141
foreach($this->dataSegments as $segment){
@@ -146,6 +146,12 @@ private function estimateTotalBitLength():int{
146146
// mode length bits margin to the next breakpoint
147147
$margin += ($segment instanceof Byte) ? 8 : 2;
148148
}
149+
150+
if($segment instanceof Hanzi){
151+
// Hanzi mode sets an additional 4 bit long subset identifier
152+
$length += 4;
153+
}
154+
149155
}
150156

151157
foreach([9, 26, 40] as $breakpoint){
@@ -168,7 +174,7 @@ private function estimateTotalBitLength():int{
168174
*
169175
* @throws \chillerlan\QRCode\Data\QRCodeDataException
170176
*/
171-
private function getMinimumVersion():Version{
177+
public function getMinimumVersion():Version{
172178

173179
if($this->options->version !== Version::AUTO){
174180
return new Version($this->options->version);

0 commit comments

Comments
 (0)