🛀 data mode rework

This commit is contained in:
codemasher
2020-11-21 18:40:53 +01:00
parent 9f5d0bc060
commit 8bd573ddfd
7 changed files with 64 additions and 74 deletions
+2 -32
View File
@@ -18,11 +18,6 @@ use chillerlan\QRCode\Helpers\BitBuffer;
*/
abstract class QRDataModeAbstract implements QRDataModeInterface{
/**
* the current data mode: Num, Alphanum, Kanji, Byte
*/
protected int $datamode;
/**
* mode length bits for the version breakpoints 1-9, 10-26 and 27-40
*
@@ -35,30 +30,17 @@ abstract class QRDataModeAbstract implements QRDataModeInterface{
*/
protected string $data;
/**
* a BitBuffer instance
*/
protected BitBuffer $bitBuffer;
/**
* QRDataModeAbstract constructor.
*
* @throws \chillerlan\QRCode\Data\QRCodeDataException
*/
public function __construct(BitBuffer $bitBuffer, string $data){
// do we need this here? we check during write anyways.
# if(!static::validateString($data)){
# throw new QRCodeDataException('invalid data string');
# }
$this->bitBuffer = $bitBuffer;
public function __construct(string $data){
$this->data = $data;
}
/**
* returns the character count of the $data string
*/
protected function getLength():int{
protected function getCharCount():int{
return strlen($this->data);
}
@@ -86,16 +68,4 @@ abstract class QRDataModeAbstract implements QRDataModeInterface{
throw new QRCodeDataException(sprintf('invalid version number: %d', $version));
}
/**
*
*/
protected function writeSegmentHeader(int $version):void{
$this->bitBuffer
->put($this->datamode, 4)
->put($this->getLength(), $this->getLengthBitsForVersion($version))
;
}
}