🚿 QROptions::$dataMode -> $dataModeOverride

This commit is contained in:
codemasher
2020-04-05 02:21:14 +02:00
parent 6c293a0b49
commit 0d66c5a2f3
4 changed files with 10 additions and 10 deletions
+6 -6
View File
@@ -20,7 +20,7 @@ use chillerlan\QRCode\Output\{
};
use chillerlan\Settings\SettingsContainerInterface;
use function call_user_func_array, class_exists, in_array, mb_internal_encoding, ord, strlen;
use function call_user_func_array, class_exists, in_array, mb_internal_encoding, ord, strlen, strtolower;
/**
* Turns a text string into a Model 2 QR Code
@@ -139,10 +139,10 @@ class QRCode{
* @var string[]
*/
protected const DATA_INTERFACES = [
'Number' => Number::class,
'AlphaNum' => AlphaNum::class,
'Kanji' => Kanji::class,
'Byte' => Byte::class,
'number' => Number::class,
'alphanum' => AlphaNum::class,
'kanji' => Kanji::class,
'byte' => Byte::class,
];
/**
@@ -231,7 +231,7 @@ class QRCode{
// allow forcing the data mode
// see https://github.com/chillerlan/php-qrcode/issues/39
$interface = $this::DATA_INTERFACES[$this->options->dataMode] ?? null;
$interface = $this::DATA_INTERFACES[strtolower($this->options->dataModeOverride)] ?? null;
if($interface !== null){
return new $interface($this->options, $data);
+1 -1
View File
@@ -24,7 +24,7 @@ use chillerlan\Settings\SettingsContainerAbstract;
* @property int $maskPattern
* @property bool $addQuietzone
* @property int $quietzoneSize
* @property string|null $dataMode
* @property string|null $dataModeOverride
* @property string $outputType
* @property string|null $outputInterface
* @property string|null $cachefile
+2 -2
View File
@@ -74,11 +74,11 @@ trait QROptionsTrait{
/**
* Use this to circumvent the data mode detection and force the usage of the given mode.
*
* valid modes are: Number, AlphaNum, Kanji, Byte
* valid modes are: Number, AlphaNum, Kanji, Byte (case insensitive)
*
* @see https://github.com/chillerlan/php-qrcode/issues/39
*/
protected ?string $dataMode = null;
protected ?string $dataModeOverride = null;
/**
* The output type
+1 -1
View File
@@ -132,7 +132,7 @@ class QRCodeTest extends QRTestAbstract{
$this->expectException(QRCodeDataException::class);
$this->expectExceptionMessage('illegal char:');
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['dataMode' => 'AlphaNum'])]);
$this->qrcode = $this->reflection->newInstanceArgs([new QROptions(['dataModeOverride' => 'AlphaNum'])]);
$this->qrcode->initDataInterface(random_bytes(32));
}