mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-29 23:27:11 +00:00
:octocat: +data mode decodeSegment() (WIP)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user