:octocat: +data mode decodeSegment() (WIP)

This commit is contained in:
codemasher
2021-01-23 04:10:37 +01:00
parent c06e3f1cd6
commit 22f1672fac
6 changed files with 228 additions and 19 deletions
+21
View File
@@ -60,4 +60,25 @@ final class Byte extends QRDataModeAbstract{
}
/**
* @inheritdoc
*
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
public static function decodeSegment(BitBuffer $bitBuffer, int $versionNumber):string{
$length = $bitBuffer->read(Mode::getLengthBitsForVersion(self::$datamode, $versionNumber));
if($bitBuffer->available() < 8 * $length){
throw new QRCodeDataException('not enough bits available');
}
$readBytes = '';
for($i = 0; $i < $length; $i++){
$readBytes .= \chr($bitBuffer->read(8));
}
return $readBytes;
}
}