Skip to content

Commit

Permalink
chore: update coding style (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi authored Sep 16, 2024
1 parent 5b9a887 commit 6b2d544
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.26.0" installed="3.26.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="php-cs-fixer" version="^3.64.0" installed="3.64.0" location="./tools/php-cs-fixer" copy="false"/>
</phive>
13 changes: 4 additions & 9 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => <<<EOF
This file is part of rekalogika/print-src package.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* test: update phpstan and psalm

## 1.2.0

* chore: update coding style

## 1.1.0

* Supports Symfony 7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function load(array $configs, ContainerBuilder $container): void
{
$loader = new PhpFileLoader(
$container,
new FileLocator(__DIR__ . '/../../config')
new FileLocator(__DIR__ . '/../../config'),
);

$loader->load('services.php');
Expand Down
7 changes: 3 additions & 4 deletions packages/gotenberg-pdf-bundle/src/GotenbergPdfGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 6 additions & 7 deletions packages/print/src/PageLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ public static function inMm(
$a / 1000,
$a / 1000,
$a / 1000,
$pageOrientation
$pageOrientation,
);
} elseif ($c === null) {
return new self(
$a / 1000,
$b / 1000,
$a / 1000,
$b / 1000,
$pageOrientation
$pageOrientation,
);
} elseif ($d === null) {
return new self(
$a / 1000,
$b / 1000,
$c / 1000,
$b / 1000,
$pageOrientation
$pageOrientation,
);
}
return new self(
$a / 1000,
$b / 1000,
$c / 1000,
$d / 1000,
$pageOrientation
$pageOrientation,
);

}
Expand All @@ -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
{
Expand Down
3 changes: 1 addition & 2 deletions packages/print/src/Paper.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ public static function tabloid(): self
private function __construct(
private float $width,
private float $height,
) {
}
) {}

public function getWidth(): float
{
Expand Down
8 changes: 4 additions & 4 deletions tests/PageLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testOneMargin(): void
{
$pageLayout = PageLayout::inMm(
PageOrientation::Portrait,
10
10,
);

$this->assertEquals(0.01, $pageLayout->getTopMargin());
Expand All @@ -37,7 +37,7 @@ public function testTwoMargins(): void
$pageLayout = PageLayout::inMm(
PageOrientation::Portrait,
10,
20
20,
);

$this->assertEquals(0.01, $pageLayout->getTopMargin());
Expand All @@ -52,7 +52,7 @@ public function testThreeMargins(): void
PageOrientation::Portrait,
10,
20,
30
30,
);

$this->assertEquals(0.01, $pageLayout->getTopMargin());
Expand All @@ -68,7 +68,7 @@ public function testFourMargins(): void
10,
20,
30,
40
40,
);

$this->assertEquals(0.01, $pageLayout->getTopMargin());
Expand Down

0 comments on commit 6b2d544

Please sign in to comment.