From efc2878ed018fedac5458a3ae8f1f816f5518196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20DANGUY?= <91881914+Swanoo@users.noreply.github.com> Date: Fri, 23 Jun 2023 11:26:56 +0200 Subject: [PATCH] fix: Change interfaces function names --- src/Core/Bridge/FromFileToStringToPdf.php | 5 ++--- src/Core/Bridge/FromStringToFileToPdf.php | 7 +++---- src/Core/FileToPdf.php | 4 +--- src/Core/StringToPdf.php | 4 +--- src/Core/UriToPdf.php | 11 +++++++++++ 5 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 src/Core/UriToPdf.php diff --git a/src/Core/Bridge/FromFileToStringToPdf.php b/src/Core/Bridge/FromFileToStringToPdf.php index 6d1038a3..b159aeac 100644 --- a/src/Core/Bridge/FromFileToStringToPdf.php +++ b/src/Core/Bridge/FromFileToStringToPdf.php @@ -7,7 +7,6 @@ use KnpLabs\Snappy\Core\FileToPdf; use KnpLabs\Snappy\Core\StringToPdf; use Psr\Http\Message\StreamInterface; -use SplFileInfo; final class FromFileToStringToPdf implements FileToPdf { @@ -15,9 +14,9 @@ public function __construct(private StringToPdf $stringToPdf) { } - public function generate(SplFileInfo $file, ArrayAccess|array $options = []): StreamInterface + public function generateFromFile(\SplFileInfo $file, \ArrayAccess|array $options = []): StreamInterface { - return $this->stringToPdf->generate( + return $this->stringToPdf->generateFromString( file_get_contents($file->getPathname()), $options, ); diff --git a/src/Core/Bridge/FromStringToFileToPdf.php b/src/Core/Bridge/FromStringToFileToPdf.php index b63a7685..fd22e359 100644 --- a/src/Core/Bridge/FromStringToFileToPdf.php +++ b/src/Core/Bridge/FromStringToFileToPdf.php @@ -7,7 +7,6 @@ use KnpLabs\Snappy\Core\FileToPdf; use KnpLabs\Snappy\Core\StringToPdf; use Psr\Http\Message\StreamInterface; -use SplFileInfo; final class FromStringToFileToPdf implements StringToPdf { @@ -15,16 +14,16 @@ public function __construct(private FileToPdf $fileToPdf) { } - public function generate(string $html, ArrayAccess|array $options = []): StreamInterface + public function generateFromString(string $html, \ArrayAccess|array $options = []): StreamInterface { $path = tempnam(sys_get_temp_dir(), 'snappy_'); try { file_put_contents($path, $html); - $file = new SplFileInfo($path); + $file = new \SplFileInfo($path); - $stream = $this->fileToPdf->generate($file, $options); + $stream = $this->fileToPdf->generateFromFile($file, $options); } finally { unlink($path); } diff --git a/src/Core/FileToPdf.php b/src/Core/FileToPdf.php index b252e0d5..9cd2db76 100644 --- a/src/Core/FileToPdf.php +++ b/src/Core/FileToPdf.php @@ -2,11 +2,9 @@ namespace KnpLabs\Snappy\Core; -use ArrayAccess; use Psr\Http\Message\StreamInterface; -use SplFileInfo; interface FileToPdf { - public function generate(SplFileInfo $file, ArrayAccess|array $options = []): StreamInterface; + public function generateFromFile(\SplFileInfo $file, \ArrayAccess|array $options = []): StreamInterface; } diff --git a/src/Core/StringToPdf.php b/src/Core/StringToPdf.php index 046438d5..aebb85fe 100644 --- a/src/Core/StringToPdf.php +++ b/src/Core/StringToPdf.php @@ -2,11 +2,9 @@ namespace KnpLabs\Snappy\Core; -use ArrayAccess; use Psr\Http\Message\StreamInterface; -use SplFileInfo; interface StringToPdf { - public function generate(string $html, ArrayAccess|array $options = []): StreamInterface; + public function generateFromString(string $html, \ArrayAccess|array $options = []): StreamInterface; } diff --git a/src/Core/UriToPdf.php b/src/Core/UriToPdf.php new file mode 100644 index 00000000..f30a6ecf --- /dev/null +++ b/src/Core/UriToPdf.php @@ -0,0 +1,11 @@ +