:octocat: make datamode field static

This commit is contained in:
codemasher
2021-01-23 01:26:11 +01:00
parent 700af4b53e
commit c06e3f1cd6
6 changed files with 16 additions and 16 deletions
+3 -3
View File
@@ -38,7 +38,7 @@ final class AlphaNum extends QRDataModeAbstract{
'+' => 40, '-' => 41, '.' => 42, '/' => 43, ':' => 44,
];
protected int $datamode = Mode::DATA_ALPHANUM;
protected static int $datamode = Mode::DATA_ALPHANUM;
/**
* @inheritdoc
@@ -68,8 +68,8 @@ final class AlphaNum extends QRDataModeAbstract{
$len = $this->getCharCount();
$bitBuffer
->put($this->datamode, 4)
->put($len, Mode::getLengthBitsForVersion($this->datamode, $versionNumber))
->put($this::$datamode, 4)
->put($len, Mode::getLengthBitsForVersion($this::$datamode, $versionNumber))
;
// encode 2 characters in 11 bits
+3 -3
View File
@@ -24,7 +24,7 @@ use function ord;
*/
final class Byte extends QRDataModeAbstract{
protected int $datamode = Mode::DATA_BYTE;
protected static int $datamode = Mode::DATA_BYTE;
/**
* @inheritdoc
@@ -47,8 +47,8 @@ final class Byte extends QRDataModeAbstract{
$len = $this->getCharCount();
$bitBuffer
->put($this->datamode, 4)
->put($len, Mode::getLengthBitsForVersion($this->datamode, $versionNumber))
->put($this::$datamode, 4)
->put($len, Mode::getLengthBitsForVersion($this::$datamode, $versionNumber))
;
$i = 0;
+2 -2
View File
@@ -21,7 +21,7 @@ use chillerlan\QRCode\Common\{BitBuffer, Mode};
*/
final class ECI extends QRDataModeAbstract{
protected int $datamode = Mode::DATA_ECI;
protected static int $datamode = Mode::DATA_ECI;
/**
* The current ECI encoding id
@@ -58,7 +58,7 @@ final class ECI extends QRDataModeAbstract{
*/
public function write(BitBuffer $bitBuffer, int $versionNumber):void{
$bitBuffer
->put($this->datamode, 4)
->put($this::$datamode, 4)
->put($this->encoding, 8)
;
}
+3 -3
View File
@@ -24,7 +24,7 @@ use function mb_convert_encoding, mb_detect_encoding, mb_strlen, ord, sprintf, s
*/
final class Kanji extends QRDataModeAbstract{
protected int $datamode = Mode::DATA_KANJI;
protected static int $datamode = Mode::DATA_KANJI;
public function __construct(string $data){
parent::__construct($data);
@@ -75,8 +75,8 @@ final class Kanji extends QRDataModeAbstract{
public function write(BitBuffer $bitBuffer, int $versionNumber):void{
$bitBuffer
->put($this->datamode, 4)
->put($this->getCharCount(), Mode::getLengthBitsForVersion($this->datamode, $versionNumber))
->put($this::$datamode, 4)
->put($this->getCharCount(), Mode::getLengthBitsForVersion($this::$datamode, $versionNumber))
;
$len = strlen($this->data);
+3 -3
View File
@@ -31,7 +31,7 @@ final class Number extends QRDataModeAbstract{
'0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9,
];
protected int $datamode = Mode::DATA_NUMBER;
protected static int $datamode = Mode::DATA_NUMBER;
/**
* @inheritdoc
@@ -61,8 +61,8 @@ final class Number extends QRDataModeAbstract{
$len = $this->getCharCount();
$bitBuffer
->put($this->datamode, 4)
->put($len, Mode::getLengthBitsForVersion($this->datamode, $versionNumber))
->put($this::$datamode, 4)
->put($len, Mode::getLengthBitsForVersion($this::$datamode, $versionNumber))
;
$i = 0;
+2 -2
View File
@@ -19,7 +19,7 @@ abstract class QRDataModeAbstract implements QRDataModeInterface{
/**
* the current data mode: Num, Alphanum, Kanji, Byte
*/
protected int $datamode;
protected static int $datamode;
/**
* The data to write
@@ -44,7 +44,7 @@ abstract class QRDataModeAbstract implements QRDataModeInterface{
* @inheritDoc
*/
public function getDataMode():int{
return $this->datamode;
return $this::$datamode;
}
}