-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a possibility of customizing with the standard paper format (#28)
- Loading branch information
1 parent
753149a
commit dd8d61d
Showing
6 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Sensiolabs\GotenbergBundle\Enum; | ||
|
||
enum PaperSize implements PaperSizeInterface | ||
{ | ||
case A0; | ||
case A1; | ||
case A2; | ||
case A3; | ||
case A4; | ||
case A5; | ||
case A6; | ||
|
||
public function width(): float | ||
{ | ||
return match ($this) { | ||
PaperSize::A0 => 33.1, | ||
PaperSize::A1 => 23.4, | ||
PaperSize::A2 => 16.54, | ||
PaperSize::A3 => 11.7, | ||
PaperSize::A4 => 8.27, | ||
PaperSize::A5 => 5.83, | ||
PaperSize::A6 => 4.13, | ||
}; | ||
} | ||
|
||
public function height(): float | ||
{ | ||
return match ($this) { | ||
PaperSize::A0 => 46.8, | ||
PaperSize::A1 => 33.1, | ||
PaperSize::A2 => 23.4, | ||
PaperSize::A3 => 16.54, | ||
PaperSize::A4 => 11.7, | ||
PaperSize::A5 => 8.27, | ||
PaperSize::A6 => 5.83, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Sensiolabs\GotenbergBundle\Enum; | ||
|
||
interface PaperSizeInterface | ||
{ | ||
public function width(): float; | ||
|
||
public function height(): float; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Sensiolabs\GotenbergBundle\Tests\Enum; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\TestCase; | ||
use Sensiolabs\GotenbergBundle\Enum\PaperSize; | ||
|
||
#[CoversClass(PaperSize::class)] | ||
final class PaperSizeTest extends TestCase | ||
{ | ||
public function testWidth(): void | ||
{ | ||
foreach (PaperSize::cases() as $size) { | ||
$size->width(); | ||
self::addToAssertionCount(1); | ||
} | ||
} | ||
|
||
public function testHeight(): void | ||
{ | ||
foreach (PaperSize::cases() as $size) { | ||
$size->height(); | ||
self::addToAssertionCount(1); | ||
} | ||
} | ||
} |