From 13a325b820faeb20945c13f81ed7edfc4ccaade8 Mon Sep 17 00:00:00 2001
From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com>
Date: Mon, 16 Sep 2024 19:23:02 +0700
Subject: [PATCH] chore: update coding style
---
.phive/phars.xml | 2 +-
.php-cs-fixer.dist.php | 13 ++++---------
CHANGELOG.md | 4 ++++
.../RekalogikaGotenbergPdfExtension.php | 2 +-
.../src/GotenbergPdfGenerator.php | 7 +++----
packages/print/src/PageLayout.php | 13 ++++++-------
packages/print/src/Paper.php | 3 +--
tests/PageLayoutTest.php | 8 ++++----
8 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/.phive/phars.xml b/.phive/phars.xml
index 2a3feb1..2b1f5c8 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index e0034d3..7481a69 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -8,27 +8,22 @@
$config = new PhpCsFixer\Config();
return $config->setRules([
- '@PSR12' => true,
- 'array_syntax' => ['syntax' => 'short'],
-
- // imports
+ '@PER-CS2.0' => true,
+ '@PER-CS2.0:risky' => true,
'fully_qualified_strict_types' => true,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
- 'no_leading_import_slash' => true,
'no_unneeded_import_alias' => true,
'no_unused_imports' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
- 'imports_order' => ['const', 'class', 'function']
+ 'imports_order' => ['class', 'function', 'const']
],
- 'single_line_after_imports' => true,
- 'no_useless_else' => true,
- 'no_useless_return' => true,
'declare_strict_types' => true,
+ 'native_function_invocation' => ['include' => ['@compiler_optimized']],
'header_comment' => [
'header' => <<load('services.php');
diff --git a/packages/gotenberg-pdf-bundle/src/GotenbergPdfGenerator.php b/packages/gotenberg-pdf-bundle/src/GotenbergPdfGenerator.php
index 1fcdaf7..2abf1ba 100644
--- a/packages/gotenberg-pdf-bundle/src/GotenbergPdfGenerator.php
+++ b/packages/gotenberg-pdf-bundle/src/GotenbergPdfGenerator.php
@@ -27,20 +27,19 @@ class GotenbergPdfGenerator implements PdfGeneratorInterface
public function __construct(
private ClientInterface $httpClient,
private string $gotenbergUrl = 'http://localhost:3000',
- ) {
- }
+ ) {}
public function generatePdfFromHtml(
string $htmlContent,
PaperInterface $paper,
PageLayoutInterface $pageLayout,
?string $header = null,
- ?string $footer = null
+ ?string $footer = null,
): StreamInterface {
$chromium = Gotenberg::chromium($this->gotenbergUrl)
->paperSize(
$paper->getWidth() * 39.3701,
- $paper->getHeight() * 39.3701
+ $paper->getHeight() * 39.3701,
)
->margins(
$pageLayout->getTopMargin() * 39.3701,
diff --git a/packages/print/src/PageLayout.php b/packages/print/src/PageLayout.php
index 00339d5..cc65787 100644
--- a/packages/print/src/PageLayout.php
+++ b/packages/print/src/PageLayout.php
@@ -31,7 +31,7 @@ public static function inMm(
$a / 1000,
$a / 1000,
$a / 1000,
- $pageOrientation
+ $pageOrientation,
);
} elseif ($c === null) {
return new self(
@@ -39,7 +39,7 @@ public static function inMm(
$b / 1000,
$a / 1000,
$b / 1000,
- $pageOrientation
+ $pageOrientation,
);
} elseif ($d === null) {
return new self(
@@ -47,7 +47,7 @@ public static function inMm(
$b / 1000,
$c / 1000,
$b / 1000,
- $pageOrientation
+ $pageOrientation,
);
}
return new self(
@@ -55,7 +55,7 @@ public static function inMm(
$b / 1000,
$c / 1000,
$d / 1000,
- $pageOrientation
+ $pageOrientation,
);
}
@@ -81,9 +81,8 @@ private function __construct(
private float $rightMargin,
private float $bottomMargin,
private float $leftMargin,
- private PageOrientation $pageOrientation
- ) {
- }
+ private PageOrientation $pageOrientation,
+ ) {}
public function getTopMargin(): float
{
diff --git a/packages/print/src/Paper.php b/packages/print/src/Paper.php
index 2bc4112..c6b76a5 100644
--- a/packages/print/src/Paper.php
+++ b/packages/print/src/Paper.php
@@ -206,8 +206,7 @@ public static function tabloid(): self
private function __construct(
private float $width,
private float $height,
- ) {
- }
+ ) {}
public function getWidth(): float
{
diff --git a/tests/PageLayoutTest.php b/tests/PageLayoutTest.php
index 22f0952..d13e120 100644
--- a/tests/PageLayoutTest.php
+++ b/tests/PageLayoutTest.php
@@ -23,7 +23,7 @@ public function testOneMargin(): void
{
$pageLayout = PageLayout::inMm(
PageOrientation::Portrait,
- 10
+ 10,
);
$this->assertEquals(0.01, $pageLayout->getTopMargin());
@@ -37,7 +37,7 @@ public function testTwoMargins(): void
$pageLayout = PageLayout::inMm(
PageOrientation::Portrait,
10,
- 20
+ 20,
);
$this->assertEquals(0.01, $pageLayout->getTopMargin());
@@ -52,7 +52,7 @@ public function testThreeMargins(): void
PageOrientation::Portrait,
10,
20,
- 30
+ 30,
);
$this->assertEquals(0.01, $pageLayout->getTopMargin());
@@ -68,7 +68,7 @@ public function testFourMargins(): void
10,
20,
30,
- 40
+ 40,
);
$this->assertEquals(0.01, $pageLayout->getTopMargin());