check for data before instancing anything

This commit is contained in:
smiley
2016-01-05 00:53:56 +01:00
parent 2e03d7d71b
commit 67c2d28b7a
+4 -4
View File
@@ -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);
}