mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-25 13:47:57 +00:00
🚿 QROptions::$dataMode -> $dataModeOverride
This commit is contained in:
+6
-6
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user