:octocat: correct treatment of VERSION_AUTO

This commit is contained in:
codemasher
2018-11-10 16:45:34 +01:00
parent c14ce3bc3c
commit 826c3ace45
2 changed files with 4 additions and 1 deletions
+3 -1
View File
@@ -246,7 +246,9 @@ trait QROptionsTrait{
$this->clampRGBValues();
}
$this->version = max(1, min(40, (int)$this->version));
if($this->version !== QRCode::VERSION_AUTO){
$this->version = max(1, min(40, (int)$this->version));
}
// clamp min/max version number
$min = max(1, min(40, (int)$this->versionMin));
+1
View File
@@ -26,6 +26,7 @@ class QROptionsTest extends TestCase{
$this->assertSame(40, (new QROptions(['version' => 42]))->version);
$this->assertSame(1, (new QROptions(['version' => -42]))->version);
$this->assertSame(21, (new QROptions(['version' => 21]))->version);
$this->assertSame(QRCode::VERSION_AUTO, (new QROptions(['version' => QRCode::VERSION_AUTO]))->version); // -1
}
public function testVersionMinMaxClamp(){