mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-19 21:00:35 +00:00
:octocat: remove non-empty content restriction
This commit is contained in:
+2
-5
@@ -60,16 +60,13 @@ final class QRData{
|
||||
* @param \chillerlan\Settings\SettingsContainerInterface $options
|
||||
* @param \chillerlan\QRCode\Data\QRDataModeInterface[]|null $dataSegments
|
||||
*/
|
||||
public function __construct(SettingsContainerInterface $options, array $dataSegments = null){
|
||||
public function __construct(SettingsContainerInterface $options, array $dataSegments = []){
|
||||
$this->options = $options;
|
||||
$this->bitBuffer = new BitBuffer;
|
||||
$this->eccLevel = new EccLevel($this->options->eccLevel);
|
||||
$this->maxBitsForEcc = $this->eccLevel->getMaxBits();
|
||||
|
||||
if(!empty($dataSegments)){
|
||||
$this->setData($dataSegments);
|
||||
}
|
||||
|
||||
$this->setData($dataSegments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-6
@@ -12,7 +12,7 @@ namespace chillerlan\QRCode;
|
||||
|
||||
use chillerlan\QRCode\Common\{EccLevel, ECICharset, MaskPattern, Mode, Version};
|
||||
use chillerlan\QRCode\Data\{
|
||||
AlphaNum, Byte, ECI, Hanzi, Kanji, Number, QRCodeDataException, QRData, QRDataModeInterface, QRMatrix
|
||||
AlphaNum, Byte, ECI, Hanzi, Kanji, Number, QRData, QRDataModeInterface, QRMatrix
|
||||
};
|
||||
use chillerlan\QRCode\Decoder\{Decoder, DecoderResult, GDLuminanceSource, IMagickLuminanceSource, LuminanceSourceInterface};
|
||||
use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
|
||||
@@ -228,11 +228,6 @@ class QRCode{
|
||||
* @throws \chillerlan\QRCode\Data\QRCodeDataException
|
||||
*/
|
||||
public function getMatrix():QRMatrix{
|
||||
|
||||
if(empty($this->dataSegments)){
|
||||
throw new QRCodeDataException('QRCode::getMatrix() No data given.');
|
||||
}
|
||||
|
||||
$dataInterface = new QRData($this->options, $this->dataSegments);
|
||||
$maskPattern = $this->options->maskPattern === MaskPattern::AUTO
|
||||
? MaskPattern::getBestPattern($dataInterface)
|
||||
|
||||
@@ -43,14 +43,4 @@ final class QRCodeTest extends TestCase{
|
||||
(new QRCode($this->options))->render('test');
|
||||
}
|
||||
|
||||
/**
|
||||
* tests if an exception is thrown when trying to call getMatrix() without data (empty string, no data set)
|
||||
*/
|
||||
public function testGetMatrixException():void{
|
||||
$this->expectException(QRCodeDataException::class);
|
||||
$this->expectExceptionMessage('QRCode::getMatrix() No data given.');
|
||||
|
||||
$this->qrcode->getMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user