Parcourir la source

check for data before instancing anything

smiley il y a 10 ans
Parent
commit
67c2d28b7a
1 fichiers modifiés avec 4 ajouts et 4 suppressions
  1. 4 4
      src/QRCode.php

+ 4 - 4
src/QRCode.php

@@ -105,14 +105,14 @@ class QRCode{
 	public function setData($data, QROptions $options = null){
 		$data = trim($data);
 
-		if(!$options instanceof QROptions){
-			$options = new QROptions;
-		}
-
 		if(empty($data)){
 			throw new QRCodeException('No data given.');
 		}
 
+		if(!$options instanceof QROptions){
+			$options = new QROptions;
+		}
+
 		if(!array_key_exists($options->errorCorrectLevel, QRConst::RSBLOCK)){
 			throw new QRCodeException('Invalid error correct level: '.$options->errorCorrectLevel);
 		}