Explorar el Código

:octocat: remove non-empty content restriction

smiley hace 2 años
padre
commit
ca56fe5ca9
Se han modificado 3 ficheros con 3 adiciones y 21 borrados
  1. 2 5
      src/Data/QRData.php
  2. 1 6
      src/QRCode.php
  3. 0 10
      tests/QRCodeTest.php

+ 2 - 5
src/Data/QRData.php

@@ -60,16 +60,13 @@ final class QRData{
 	 * @param \chillerlan\Settings\SettingsContainerInterface    $options
 	 * @param \chillerlan\Settings\SettingsContainerInterface    $options
 	 * @param \chillerlan\QRCode\Data\QRDataModeInterface[]|null $dataSegments
 	 * @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->options       = $options;
 		$this->bitBuffer     = new BitBuffer;
 		$this->bitBuffer     = new BitBuffer;
 		$this->eccLevel      = new EccLevel($this->options->eccLevel);
 		$this->eccLevel      = new EccLevel($this->options->eccLevel);
 		$this->maxBitsForEcc = $this->eccLevel->getMaxBits();
 		$this->maxBitsForEcc = $this->eccLevel->getMaxBits();
 
 
-		if(!empty($dataSegments)){
-			$this->setData($dataSegments);
-		}
-
+		$this->setData($dataSegments);
 	}
 	}
 
 
 	/**
 	/**

+ 1 - 6
src/QRCode.php

@@ -12,7 +12,7 @@ namespace chillerlan\QRCode;
 
 
 use chillerlan\QRCode\Common\{EccLevel, ECICharset, MaskPattern, Mode, Version};
 use chillerlan\QRCode\Common\{EccLevel, ECICharset, MaskPattern, Mode, Version};
 use chillerlan\QRCode\Data\{
 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\Decoder\{Decoder, DecoderResult, GDLuminanceSource, IMagickLuminanceSource, LuminanceSourceInterface};
 use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
 use chillerlan\QRCode\Output\{QRCodeOutputException, QROutputInterface};
@@ -228,11 +228,6 @@ class QRCode{
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 * @throws \chillerlan\QRCode\Data\QRCodeDataException
 	 */
 	 */
 	public function getMatrix():QRMatrix{
 	public function getMatrix():QRMatrix{
-
-		if(empty($this->dataSegments)){
-			throw new QRCodeDataException('QRCode::getMatrix() No data given.');
-		}
-
 		$dataInterface = new QRData($this->options, $this->dataSegments);
 		$dataInterface = new QRData($this->options, $this->dataSegments);
 		$maskPattern   = $this->options->maskPattern === MaskPattern::AUTO
 		$maskPattern   = $this->options->maskPattern === MaskPattern::AUTO
 			? MaskPattern::getBestPattern($dataInterface)
 			? MaskPattern::getBestPattern($dataInterface)

+ 0 - 10
tests/QRCodeTest.php

@@ -43,14 +43,4 @@ final class QRCodeTest extends TestCase{
 		(new QRCode($this->options))->render('test');
 		(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();
-	}
-
 }
 }