mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-09-15 12:16:25 +00:00
🚿 phan happy
This commit is contained in:
@@ -76,7 +76,7 @@ class MaskPatternTester{
|
||||
continue;
|
||||
}
|
||||
|
||||
if($this->matrix->check($x + $rx, $y + $ry) === ($val >> 8 > 0)){
|
||||
if($this->matrix->check($x + $rx, $y + $ry) === (($val >> 8) > 0)){
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace chillerlan\QRCode\Data;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QRCodeException};
|
||||
use chillerlan\QRCode\QRCode;
|
||||
use chillerlan\QRCode\Helpers\{BitBuffer, Polynomial};
|
||||
use chillerlan\Settings\SettingsContainerInterface;
|
||||
|
||||
@@ -93,10 +93,8 @@ abstract class QRDataAbstract implements QRDataInterface{
|
||||
? $this->getMinimumVersion()
|
||||
: $this->options->version;
|
||||
|
||||
$this->matrixdata = $this
|
||||
->writeBitBuffer($data)
|
||||
->maskECC()
|
||||
;
|
||||
$this->writeBitBuffer($data);
|
||||
$this->matrixdata = $this->maskECC();
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -170,7 +168,7 @@ abstract class QRDataAbstract implements QRDataInterface{
|
||||
*
|
||||
* @throws \chillerlan\QRCode\QRCodeException
|
||||
*/
|
||||
protected function writeBitBuffer(string $data):QRDataInterface{
|
||||
protected function writeBitBuffer(string $data):void{
|
||||
$this->bitBuffer = new BitBuffer;
|
||||
|
||||
$MAX_BITS = $this::MAX_BITS[$this->version][QRCode::ECC_MODES[$this->options->eccLevel]];
|
||||
@@ -214,7 +212,6 @@ abstract class QRDataAbstract implements QRDataInterface{
|
||||
$this->bitBuffer->put(0x11, 8);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +280,7 @@ abstract class QRDataAbstract implements QRDataInterface{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*
|
||||
*/
|
||||
protected function poly(int $key, int $count):array{
|
||||
$rsPoly = new Polynomial;
|
||||
|
||||
@@ -216,7 +216,7 @@ class QRMatrix{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int[][]
|
||||
*/
|
||||
public function matrix():array{
|
||||
return $this->matrix;
|
||||
|
||||
@@ -59,6 +59,9 @@ class Polynomial{
|
||||
[ 27, 116], [ 54, 214], [108, 244], [216, 234], [173, 168], [ 71, 80], [142, 88], [ 1, 175],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected array $num = [];
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ use chillerlan\Settings\SettingsContainerAbstract;
|
||||
* @property int $eccLevel
|
||||
* @property int $maskPattern
|
||||
* @property bool $addQuietzone
|
||||
* @property bool $quietzoneSize
|
||||
* @property int $quietzoneSize
|
||||
*
|
||||
* @property string $dataMode
|
||||
* @property string $outputType
|
||||
@@ -32,7 +32,7 @@ use chillerlan\Settings\SettingsContainerAbstract;
|
||||
* @property int $scale
|
||||
*
|
||||
* @property string $cssClass
|
||||
* @property string $svgOpacity
|
||||
* @property float $svgOpacity
|
||||
* @property string $svgDefs
|
||||
* @property int $svgViewBoxSize
|
||||
*
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace chillerlan\QRCode;
|
||||
|
||||
use function array_values, count, is_array, is_numeric, max, min, sprintf;
|
||||
use function array_values, count, is_numeric, max, min, sprintf;
|
||||
|
||||
trait QROptionsTrait{
|
||||
|
||||
|
||||
+25
-9
@@ -22,10 +22,18 @@ class QROptionsTest extends TestCase{
|
||||
protected SettingsContainerInterface $options;
|
||||
|
||||
public function testVersionClamp():void{
|
||||
$this::assertSame(40, (new QROptions(['version' => 42]))->version);
|
||||
$this::assertSame(1, (new QROptions(['version' => -42]))->version);
|
||||
$this::assertSame(21, (new QROptions(['version' => 21]))->version);
|
||||
$this::assertSame(QRCode::VERSION_AUTO, (new QROptions)->version); // QRCode::VERSION_AUTO = -1, default
|
||||
$o = new QROptions(['version' => 42]);
|
||||
$this::assertSame(40, $o->version);
|
||||
|
||||
$o = new QROptions(['version' => -42]);
|
||||
$this::assertSame(1, $o->version);
|
||||
|
||||
$o = new QROptions(['version' => 21]);
|
||||
$this::assertSame(21, $o->version);
|
||||
|
||||
// QRCode::VERSION_AUTO = -1, default
|
||||
$o = new QROptions;
|
||||
$this::assertSame(QRCode::VERSION_AUTO, $o->version);
|
||||
}
|
||||
|
||||
public function testVersionMinMaxClamp():void{
|
||||
@@ -50,16 +58,23 @@ class QROptionsTest extends TestCase{
|
||||
}
|
||||
|
||||
public function testMaskPatternClamp():void{
|
||||
$this::assertSame(7, (new QROptions(['maskPattern' => 42]))->maskPattern);
|
||||
$this::assertSame(0, (new QROptions(['maskPattern' => -42]))->maskPattern);
|
||||
$this::assertSame(QRCode::MASK_PATTERN_AUTO, (new QROptions)->maskPattern); // QRCode::MASK_PATTERN_AUTO = -1, default
|
||||
$o = new QROptions(['maskPattern' => 42]);
|
||||
$this::assertSame(7, $o->maskPattern);
|
||||
|
||||
$o = new QROptions(['maskPattern' => -42]);
|
||||
$this::assertSame(0, $o->maskPattern);
|
||||
|
||||
// QRCode::MASK_PATTERN_AUTO = -1, default
|
||||
$o = new QROptions;
|
||||
$this::assertSame(QRCode::MASK_PATTERN_AUTO, $o->maskPattern);
|
||||
}
|
||||
|
||||
public function testInvalidEccLevelException():void{
|
||||
$this->expectException(QRCodeException::class);
|
||||
$this->expectExceptionMessage('Invalid error correct level: 42');
|
||||
|
||||
new QROptions(['eccLevel' => 42]);
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$o = new QROptions(['eccLevel' => 42]);
|
||||
}
|
||||
|
||||
public function testClampRGBValues():void{
|
||||
@@ -74,6 +89,7 @@ class QROptionsTest extends TestCase{
|
||||
$this->expectException(QRCodeException::class);
|
||||
$this->expectExceptionMessage('Invalid RGB value.');
|
||||
|
||||
new QROptions(['imageTransparencyBG' => ['r', 'g', 'b']]);
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$o = new QROptions(['imageTransparencyBG' => ['r', 'g', 'b']]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user