Skip to content

Commit 0e2eb33

Browse files
committed
:octocat: clamp SVG circle radius
1 parent 9e2681e commit 0e2eb33

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/QROptionsTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,4 +475,11 @@ protected function set_logoSpaceStartY(?int $value):void{
475475
$this->logoSpaceStartY = $value === null ? null : $this->clampLogoSpaceValue($value);
476476
}
477477

478+
/**
479+
* clamp/set SVG circle radius
480+
*/
481+
protected function set_circleRadius(float $circleRadius):void{
482+
$this->circleRadius = max(0.1, min(0.75, $circleRadius));
483+
}
484+
478485
}

tests/QROptionsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,24 @@ public function testLogoSpaceStartNullable():void{
178178
$this::assertNull($o->logoSpaceStartY);
179179
}
180180

181+
/**
182+
* @return float[][]
183+
*/
184+
public function circleRadiusProvider():array{
185+
return [
186+
[0.0, 0.1],
187+
[0.5, 0.5],
188+
[1.5, 0.75],
189+
];
190+
}
191+
192+
/**
193+
* @dataProvider circleRadiusProvider
194+
*/
195+
public function testClampCircleRadius(float $value, float $expected):void{
196+
$o = new QROptions(['circleRadius' => $value]);
197+
198+
$this::assertSame($expected, $o->circleRadius);
199+
}
200+
181201
}

0 commit comments

Comments
 (0)