|
@@ -104,7 +104,7 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
public function setData(string $data):QRDataInterface{
|
|
public function setData(string $data):QRDataInterface{
|
|
|
|
|
|
|
|
if($this->datamode === QRCode::DATA_KANJI){
|
|
if($this->datamode === QRCode::DATA_KANJI){
|
|
|
- $data = mb_convert_encoding($data, 'SJIS', mb_detect_encoding($data));
|
|
|
|
|
|
|
+ $data = \mb_convert_encoding($data, 'SJIS', \mb_detect_encoding($data));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->strlen = $this->getLength($data);
|
|
$this->strlen = $this->getLength($data);
|
|
@@ -169,7 +169,7 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
* @return int
|
|
* @return int
|
|
|
*/
|
|
*/
|
|
|
protected function getLength(string $data):int{
|
|
protected function getLength(string $data):int{
|
|
|
- return strlen($data);
|
|
|
|
|
|
|
+ return \strlen($data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -182,7 +182,7 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
$maxlength = 0;
|
|
$maxlength = 0;
|
|
|
|
|
|
|
|
// guess the version number within the given range
|
|
// guess the version number within the given range
|
|
|
- foreach(range($this->options->versionMin, $this->options->versionMax) as $version){
|
|
|
|
|
|
|
+ foreach(\range($this->options->versionMin, $this->options->versionMax) as $version){
|
|
|
$maxlength = $this::MAX_LENGTH[$version][QRCode::DATA_MODES[$this->datamode]][QRCode::ECC_MODES[$this->options->eccLevel]];
|
|
$maxlength = $this::MAX_LENGTH[$version][QRCode::DATA_MODES[$this->datamode]][QRCode::ECC_MODES[$this->options->eccLevel]];
|
|
|
|
|
|
|
|
if($this->strlen <= $maxlength){
|
|
if($this->strlen <= $maxlength){
|
|
@@ -270,13 +270,13 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
protected function maskECC():array{
|
|
protected function maskECC():array{
|
|
|
[$l1, $l2, $b1, $b2] = $this::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
|
|
[$l1, $l2, $b1, $b2] = $this::RSBLOCKS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
|
|
|
|
|
|
|
|
- $rsBlocks = array_fill(0, $l1, [$b1, $b2]);
|
|
|
|
|
|
|
+ $rsBlocks = \array_fill(0, $l1, [$b1, $b2]);
|
|
|
$rsCount = $l1 + $l2;
|
|
$rsCount = $l1 + $l2;
|
|
|
- $this->ecdata = array_fill(0, $rsCount, null);
|
|
|
|
|
|
|
+ $this->ecdata = \array_fill(0, $rsCount, null);
|
|
|
$this->dcdata = $this->ecdata;
|
|
$this->dcdata = $this->ecdata;
|
|
|
|
|
|
|
|
if($l2 > 0){
|
|
if($l2 > 0){
|
|
|
- $rsBlocks = array_merge($rsBlocks, array_fill(0, $l2, [$b1 + 1, $b2 + 1]));
|
|
|
|
|
|
|
+ $rsBlocks = \array_merge($rsBlocks, \array_fill(0, $l2, [$b1 + 1, $b2 + 1]));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$totalCodeCount = 0;
|
|
$totalCodeCount = 0;
|
|
@@ -288,9 +288,9 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
[$rsBlockTotal, $dcCount] = $block;
|
|
[$rsBlockTotal, $dcCount] = $block;
|
|
|
|
|
|
|
|
$ecCount = $rsBlockTotal - $dcCount;
|
|
$ecCount = $rsBlockTotal - $dcCount;
|
|
|
- $maxDcCount = max($maxDcCount, $dcCount);
|
|
|
|
|
- $maxEcCount = max($maxEcCount, $ecCount);
|
|
|
|
|
- $this->dcdata[$key] = array_fill(0, $dcCount, null);
|
|
|
|
|
|
|
+ $maxDcCount = \max($maxDcCount, $dcCount);
|
|
|
|
|
+ $maxEcCount = \max($maxEcCount, $ecCount);
|
|
|
|
|
+ $this->dcdata[$key] = \array_fill(0, $dcCount, null);
|
|
|
|
|
|
|
|
foreach($this->dcdata[$key] as $a => $_z){
|
|
foreach($this->dcdata[$key] as $a => $_z){
|
|
|
$this->dcdata[$key][$a] = 0xff & $this->bitBuffer->buffer[$a + $offset];
|
|
$this->dcdata[$key][$a] = 0xff & $this->bitBuffer->buffer[$a + $offset];
|
|
@@ -307,13 +307,13 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
$totalCodeCount += $rsBlockTotal;
|
|
$totalCodeCount += $rsBlockTotal;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $data = array_fill(0, $totalCodeCount, null);
|
|
|
|
|
|
|
+ $data = \array_fill(0, $totalCodeCount, null);
|
|
|
$index = 0;
|
|
$index = 0;
|
|
|
|
|
|
|
|
$mask = function($arr, $count) use (&$data, &$index, $rsCount){
|
|
$mask = function($arr, $count) use (&$data, &$index, $rsCount){
|
|
|
for($x = 0; $x < $count; $x++){
|
|
for($x = 0; $x < $count; $x++){
|
|
|
for($y = 0; $y < $rsCount; $y++){
|
|
for($y = 0; $y < $rsCount; $y++){
|
|
|
- if($x < count($arr[$y])){
|
|
|
|
|
|
|
+ if($x < \count($arr[$y])){
|
|
|
$data[$index] = $arr[$y][$x];
|
|
$data[$index] = $arr[$y][$x];
|
|
|
$index++;
|
|
$index++;
|
|
|
}
|
|
}
|
|
@@ -342,19 +342,19 @@ abstract class QRDataAbstract implements QRDataInterface{
|
|
|
$rsPoly->multiply($modPoly->getNum());
|
|
$rsPoly->multiply($modPoly->getNum());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $rsPolyCount = count($rsPoly->getNum());
|
|
|
|
|
|
|
+ $rsPolyCount = \count($rsPoly->getNum());
|
|
|
|
|
|
|
|
$modPoly
|
|
$modPoly
|
|
|
->setNum($this->dcdata[$key], $rsPolyCount - 1)
|
|
->setNum($this->dcdata[$key], $rsPolyCount - 1)
|
|
|
->mod($rsPoly->getNum())
|
|
->mod($rsPoly->getNum())
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
- $this->ecdata[$key] = array_fill(0, $rsPolyCount - 1, null);
|
|
|
|
|
|
|
+ $this->ecdata[$key] = \array_fill(0, $rsPolyCount - 1, null);
|
|
|
$num = $modPoly->getNum();
|
|
$num = $modPoly->getNum();
|
|
|
|
|
|
|
|
return [
|
|
return [
|
|
|
$num,
|
|
$num,
|
|
|
- count($num) - count($this->ecdata[$key]),
|
|
|
|
|
|
|
+ \count($num) - \count($this->ecdata[$key]),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|