:octocat: remove non-empty content restriction

This commit is contained in:
smiley
2023-03-02 23:01:54 +01:00
parent 2b86a24ccc
commit ca56fe5ca9
3 changed files with 3 additions and 21 deletions
+2 -5
View File
@@ -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
View File
@@ -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)
-10
View File
@@ -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();
}
}