Sfoglia il codice sorgente

:octocat: +QRCode::setOptions()

smiley 2 anni fa
parent
commit
d98b56b55e
2 ha cambiato i file con 13 aggiunte e 5 eliminazioni
  1. 10 2
      src/QRCode.php
  2. 3 3
      tests/QRCodeTest.php

+ 10 - 2
src/QRCode.php

@@ -183,12 +183,20 @@ class QRCode{
 	 * Sets the options instance
 	 */
 	public function __construct(SettingsContainerInterface $options = null){
-		$this->options = $options ?? new QROptions;
+		$this->setOptions($options ?? new QROptions);
+	}
+
+	/**
+	 * Sets an options instance
+	 */
+	public function setOptions(SettingsContainerInterface $options):self{
+		$this->options = $options;
 
-		// I hate this less
 		if($this->options->readerUseImagickIfAvailable){
 			$this->luminanceSourceFQN = IMagickLuminanceSource::class;
 		}
+
+		return $this;
 	}
 
 	/**

+ 3 - 3
tests/QRCodeTest.php

@@ -40,7 +40,7 @@ final class QRCodeTest extends TestCase{
 
 		$this->options->outputType = 'foo';
 
-		(new QRCode($this->options))->render('test');
+		$this->qrcode->setOptions($this->options)->render('test');
 	}
 
 	/**
@@ -52,7 +52,7 @@ final class QRCodeTest extends TestCase{
 
 		$this->options->outputType = QROutputInterface::CUSTOM;
 
-		(new QRCode($this->options))->render('test');
+		$this->qrcode->setOptions($this->options)->render('test');
 	}
 
 	/**
@@ -65,7 +65,7 @@ final class QRCodeTest extends TestCase{
 		$this->options->outputType      = QROutputInterface::CUSTOM;
 		$this->options->outputInterface = stdClass::class;
 
-		(new QRCode($this->options))->render('test');
+		$this->qrcode->setOptions($this->options)->render('test');
 	}
 
 }