Ver Fonte

options overall optional

smiley há 10 anos atrás
pai
commit
645d32c062
1 ficheiros alterados com 5 adições e 6 exclusões
  1. 5 6
      src/QRCode.php

+ 5 - 6
src/QRCode.php

@@ -92,11 +92,6 @@ class QRCode{
 	public function __construct($data, QROutputInterface $output, QROptions $options = null){
 	public function __construct($data, QROutputInterface $output, QROptions $options = null){
 		$this->qrOutputInterface = $output;
 		$this->qrOutputInterface = $output;
 		$this->bitBuffer = new BitBuffer;
 		$this->bitBuffer = new BitBuffer;
-
-		if(!$options instanceof QROptions){
-			$options = new QROptions;
-		}
-
 		$this->setData($data, $options);
 		$this->setData($data, $options);
 	}
 	}
 
 
@@ -107,9 +102,13 @@ class QRCode{
 	 * @return $this
 	 * @return $this
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 * @throws \chillerlan\QRCode\QRCodeException
 	 */
 	 */
-	public function setData($data, QROptions $options){
+	public function setData($data, QROptions $options = null){
 		$data = trim($data);
 		$data = trim($data);
 
 
+		if(!$options instanceof QROptions){
+			$options = new QROptions;
+		}
+
 		if(empty($data)){
 		if(empty($data)){
 			throw new QRCodeException('No data given.');
 			throw new QRCodeException('No data given.');
 		}
 		}