mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-23 17:33:10 +00:00
:octocat: move version clamp to options
This commit is contained in:
@@ -182,7 +182,7 @@ abstract class QRDataAbstract implements QRDataInterface{
|
||||
$maxlength = 0;
|
||||
|
||||
// guess the version number within the given range
|
||||
foreach(range(max(1, $this->options->versionMin), min($this->options->versionMax, 40)) as $version){
|
||||
foreach(range($this->options->versionMin, $this->options->versionMax) as $version){
|
||||
$maxlength = $this::MAX_LENGTH[$version][QRCode::DATA_MODES[$this->datamode]][QRCode::ECC_MODES[$this->options->eccLevel]];
|
||||
|
||||
if($this->strlen <= $maxlength){
|
||||
|
||||
@@ -247,10 +247,11 @@ trait QROptionsTrait{
|
||||
$this->version = (int)$this->version;
|
||||
|
||||
// clamp min/max version number
|
||||
$max = $this->versionMax;
|
||||
$min = $this->versionMin;
|
||||
$this->versionMin = (int)min($min, $max);
|
||||
$this->versionMax = (int)max($min, $max);
|
||||
$min = min(max(1, (int)$this->versionMin), 40);
|
||||
$max = max(1, min((int)$this->versionMax, 40));
|
||||
|
||||
$this->versionMin = min($min, $max);
|
||||
$this->versionMax = max($min, $max);
|
||||
|
||||
if($this->maskPattern !== QRCode::MASK_PATTERN_AUTO){
|
||||
$this->maskPattern = min(7, max(0, (int)$this->maskPattern));
|
||||
|
||||
Reference in New Issue
Block a user