diff --git a/src/Data/QRData.php b/src/Data/QRData.php index 41a6562e7..48cd5fd36 100644 --- a/src/Data/QRData.php +++ b/src/Data/QRData.php @@ -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); } /** diff --git a/src/QRCode.php b/src/QRCode.php index 127f9a668..62145fe2f 100755 --- a/src/QRCode.php +++ b/src/QRCode.php @@ -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) diff --git a/tests/QRCodeTest.php b/tests/QRCodeTest.php index 57b47be03..45d86ea77 100755 --- a/tests/QRCodeTest.php +++ b/tests/QRCodeTest.php @@ -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(); - } - }