mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-30 20:17:17 +00:00
:octocat: clamp SVG circle radius
This commit is contained in:
@@ -475,4 +475,11 @@ trait QROptionsTrait{
|
||||
$this->logoSpaceStartY = $value === null ? null : $this->clampLogoSpaceValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* clamp/set SVG circle radius
|
||||
*/
|
||||
protected function set_circleRadius(float $circleRadius):void{
|
||||
$this->circleRadius = max(0.1, min(0.75, $circleRadius));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -178,4 +178,24 @@ final class QROptionsTest extends TestCase{
|
||||
$this::assertNull($o->logoSpaceStartY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float[][]
|
||||
*/
|
||||
public function circleRadiusProvider():array{
|
||||
return [
|
||||
[0.0, 0.1],
|
||||
[0.5, 0.5],
|
||||
[1.5, 0.75],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider circleRadiusProvider
|
||||
*/
|
||||
public function testClampCircleRadius(float $value, float $expected):void{
|
||||
$o = new QROptions(['circleRadius' => $value]);
|
||||
|
||||
$this::assertSame($expected, $o->circleRadius);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user