Skip to content

Commit ca010b2

Browse files
committed
style: fix phpcs issues in arc math refactor
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 6c55388 commit ca010b2

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

src/Pdf/Svg/SvgArcConverter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace LibreSign\XObjectTemplate\Pdf\Svg;
99

10+
use LibreSign\XObjectTemplate\Pdf\Svg\SvgArcMath;
11+
1012
/**
1113
* Converts SVG arc commands to cubic Bézier curve approximations.
1214
*
@@ -20,7 +22,7 @@
2022
final readonly class SvgArcConverter
2123
{
2224
public function __construct(
23-
private \LibreSign\XObjectTemplate\Pdf\Svg\SvgArcMath $math = new \LibreSign\XObjectTemplate\Pdf\Svg\SvgArcMath(),
25+
private SvgArcMath $math = new SvgArcMath(),
2426
) {
2527
}
2628

src/Pdf/Svg/SvgArcMath.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,4 @@ private function calculatePrimeCoordinates(ArcParams $params): array
164164

165165
return [$primeX, $primeY];
166166
}
167-
}
167+
}

tests/Unit/Pdf/Svg/SvgArcMathTest.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ private static function assertCurveMatches(array $expected, array $actual, float
2323
self::assertCount(count($expected), $actual);
2424

2525
foreach ($expected as $index => $expectedValue) {
26-
self::assertEqualsWithDelta($expectedValue, $actual[$index], $delta, sprintf('Curve index %d differs.', $index));
26+
self::assertEqualsWithDelta(
27+
$expectedValue,
28+
$actual[$index],
29+
$delta,
30+
sprintf('Curve index %d differs.', $index),
31+
);
2732
}
2833
}
2934

@@ -114,8 +119,11 @@ public function testNormalizeArcRadiiMatchesExpectedScaleForRotatedArc(): void
114119
}
115120

116121
#[DataProvider('provideCalculateArcCenterScenarios')]
117-
public function testCalculateArcCenterBoundaryScenarios(ArcParams $params, float $expectedCenterX, float $expectedCenterY): void
118-
{
122+
public function testCalculateArcCenterBoundaryScenarios(
123+
ArcParams $params,
124+
float $expectedCenterX,
125+
float $expectedCenterY,
126+
): void {
119127
$math = new SvgArcMath();
120128

121129
[$centerX, $centerY] = $math->calculateArcCenter($params);
@@ -165,8 +173,11 @@ public static function provideCalculateArcCenterScenarios(): iterable
165173
}
166174

167175
#[DataProvider('provideCalculateArcAnglesScenarios')]
168-
public function testCalculateArcAnglesBoundaryScenarios(ArcParams $params, float $expectedStartAngle, float $expectedDeltaAngle): void
169-
{
176+
public function testCalculateArcAnglesBoundaryScenarios(
177+
ArcParams $params,
178+
float $expectedStartAngle,
179+
float $expectedDeltaAngle,
180+
): void {
170181
$math = new SvgArcMath();
171182

172183
[$startAngle, $deltaAngle] = $math->calculateArcAngles($params);
@@ -269,7 +280,9 @@ public static function provideGenerateArcCurvesScenarios(): iterable
269280
$alphaDeltaAngle = M_PI / 3.0;
270281

271282
$alphaTanHalfAngleStep = tan($alphaDeltaAngle / 2.0);
272-
$alpha = sin($alphaDeltaAngle) * (sqrt(4.0 + 3.0 * $alphaTanHalfAngleStep * $alphaTanHalfAngleStep) - 1.0) / 3.0;
283+
$alpha = sin($alphaDeltaAngle)
284+
* (sqrt(4.0 + 3.0 * $alphaTanHalfAngleStep * $alphaTanHalfAngleStep) - 1.0)
285+
/ 3.0;
273286

274287
yield 'ceil boundary keeps two segments' => [
275288
'params' => self::createCurveGenerationParams(0.0, 0.0, 10.0, 7.0, 1.0, 0.0, 0.0, $ceilDeltaAngle),
@@ -332,4 +345,4 @@ public static function provideGenerateArcCurvesScenarios(): iterable
332345
],
333346
];
334347
}
335-
}
348+
}

0 commit comments

Comments
 (0)