smiley 1 місяць тому
батько
коміт
b9d2059743
1 змінених файлів з 14 додано та 11 видалено
  1. 14 11
      src/QRCode.php

+ 14 - 11
src/QRCode.php

@@ -259,25 +259,28 @@ class QRCode{
 		$eciCharset = new ECICharset($encoding);
 		// get charset name
 		$eciCharsetName = $eciCharset->getName();
-		// convert the string to the given charset
-		if($eciCharsetName !== null){
-			$data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding());
 
-			if($data === false){
-				throw new QRCodeException('mb_convert_encoding() error'); // @codeCoverageIgnore
-			}
+		if($eciCharsetName === null){
+			throw new QRCodeException('unable to add ECI segment');
+		}
 
-			return $this
-				->addEciDesignator($eciCharset->getID())
-				->addByteSegment($data)
-			;
+		// convert the string to the given charset
+		$data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding());
+
+		if($data === false){
+			throw new QRCodeException('mb_convert_encoding() error'); // @codeCoverageIgnore
 		}
 
-		throw new QRCodeException('unable to add ECI segment');
+		return $this
+			->addEciDesignator($eciCharset->getID())
+			->addByteSegment($data)
+		;
 	}
 
 	/**
 	 * Reads a QR Code from a given file
+	 *
+	 * @codeCoverageIgnore
 	 */
 	public function readFromFile(string $path):DecoderResult{
 		return $this->readFromSource($this->luminanceSourceFQN::fromFile($path, $this->options));