🚿 sprintf'd some things

This commit is contained in:
codemasher
2019-08-09 21:14:00 +02:00
parent d6b3e6bc3b
commit ab7a11f225
9 changed files with 24 additions and 25 deletions
+5 -5
View File
@@ -16,7 +16,7 @@ use chillerlan\QRCode\{QRCode, QRCodeException};
use chillerlan\QRCode\Helpers\{BitBuffer, Polynomial};
use chillerlan\Settings\SettingsContainerInterface;
use function array_fill, array_merge, count, max, range, strlen;
use function array_fill, array_merge, count, max, mb_convert_encoding, mb_detect_encoding, range, sprintf, strlen;
/**
* Processes the binary data and maps it on a matrix which is then being returned
@@ -106,7 +106,7 @@ abstract class QRDataAbstract implements QRDataInterface{
public function setData(string $data):QRDataInterface{
if($this->datamode === QRCode::DATA_KANJI){
$data = \mb_convert_encoding($data, 'SJIS', \mb_detect_encoding($data));
$data = mb_convert_encoding($data, 'SJIS', mb_detect_encoding($data));
}
$this->strlen = $this->getLength($data);
@@ -160,7 +160,7 @@ abstract class QRDataAbstract implements QRDataInterface{
}
}
throw new QRCodeDataException('invalid version number: '.$this->version);
throw new QRCodeDataException(sprintf('invalid version number: %d', $this->version));
}
/**
@@ -192,7 +192,7 @@ abstract class QRDataAbstract implements QRDataInterface{
}
}
throw new QRCodeDataException('data exceeds '.$maxlength.' characters');
throw new QRCodeDataException(sprintf('data exceeds %d characters', $maxlength));
}
/**
@@ -227,7 +227,7 @@ abstract class QRDataAbstract implements QRDataInterface{
// there was an error writing the BitBuffer data, which is... unlikely.
if($this->bitBuffer->length > $MAX_BITS){
throw new QRCodeException('code length overflow. ('.$this->bitBuffer->length.' > '.$MAX_BITS.'bit)'); // @codeCoverageIgnore
throw new QRCodeException(sprintf('code length overflow. (%d > %d bit)', $this->bitBuffer->length, $MAX_BITS)); // @codeCoverageIgnore
}
// end code.