Skip to content

Commit b9d2059

Browse files
committed
🚿
1 parent 8237857 commit b9d2059

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/QRCode.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,25 +259,28 @@ public function addEciSegment(int $encoding, string $data):static{
259259
$eciCharset = new ECICharset($encoding);
260260
// get charset name
261261
$eciCharsetName = $eciCharset->getName();
262-
// convert the string to the given charset
263-
if($eciCharsetName !== null){
264-
$data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding());
265262

266-
if($data === false){
267-
throw new QRCodeException('mb_convert_encoding() error'); // @codeCoverageIgnore
268-
}
263+
if($eciCharsetName === null){
264+
throw new QRCodeException('unable to add ECI segment');
265+
}
269266

270-
return $this
271-
->addEciDesignator($eciCharset->getID())
272-
->addByteSegment($data)
273-
;
267+
// convert the string to the given charset
268+
$data = mb_convert_encoding($data, $eciCharsetName, mb_internal_encoding());
269+
270+
if($data === false){
271+
throw new QRCodeException('mb_convert_encoding() error'); // @codeCoverageIgnore
274272
}
275273

276-
throw new QRCodeException('unable to add ECI segment');
274+
return $this
275+
->addEciDesignator($eciCharset->getID())
276+
->addByteSegment($data)
277+
;
277278
}
278279

279280
/**
280281
* Reads a QR Code from a given file
282+
*
283+
* @codeCoverageIgnore
281284
*/
282285
public function readFromFile(string $path):DecoderResult{
283286
return $this->readFromSource($this->luminanceSourceFQN::fromFile($path, $this->options));

0 commit comments

Comments
 (0)