Skip to content

Commit c062001

Browse files
committed
feat(core): implement frontends for all backends
1 parent 3770bea commit c062001

30 files changed

+1006
-95
lines changed

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
**/composer.lock
2-
**/vendor
3-
**cache**
1+
/.php-cs-fixer.cache
2+
/.phpunit.result.cache
3+
/composer.lock
4+
/vendor

phpunit.xml.dist

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@
1313
</php>
1414

1515
<testsuites>
16-
<testsuite name="Snappy Dompdf backend">
17-
<directory>./src/Backend/Dompdf</directory>
18-
</testsuite>
19-
<testsuite name="Snappy WkHtmlToPdf backend">
20-
<directory>./src/Backend/WkHtmlToPdf</directory>
21-
</testsuite>
2216
<testsuite name="Snappy core">
23-
<directory>./src/Core/</directory>
17+
<directory>./src/Core/Tests/</directory>
2418
</testsuite>
2519
<testsuite name="Snappy Symfony framework integration">
26-
<directory>./src/Framework/Symfony/</directory>
20+
<directory>./src/Framework/Symfony/Tests/</directory>
2721
</testsuite>
2822
</testsuites>
2923
</phpunit>

src/Backend/Dompdf/DompdfAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public function __construct(DompdfFactory $factory, Options $options, private St
2626
$this->options = $options;
2727
}
2828

29-
public function generateFromDOMDocument(\DOMDocument $DOMDocument): StreamInterface
29+
public function generateFromDOMDocument(\DOMDocument $document): StreamInterface
3030
{
3131
$dompdf = $this->buildDompdf();
32-
$dompdf->loadDOM($DOMDocument);
32+
$dompdf->loadDOM($document);
3333

3434
return $this->createStream($dompdf);
3535
}

src/Core/Backend/Adapter/DOMDocumentToPdf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
interface DOMDocumentToPdf extends Adapter
1111
{
12-
public function generateFromDOMDocument(\DOMDocument $DOMDocument): StreamInterface;
12+
public function generateFromDOMDocument(\DOMDocument $document): StreamInterface;
1313
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace KNPLabs\Snappy\Core\Backend\Adapter;
6+
7+
use KNPLabs\Snappy\Core\Backend\Adapter;
8+
use Psr\Http\Message\StreamInterface;
9+
10+
interface StreamToPdf extends Adapter
11+
{
12+
public function generateFromStream(StreamInterface $stream): StreamInterface;
13+
}

src/Core/Backend/Options.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ final class Options
1111
/**
1212
* @param array<mixed> $extraOptions
1313
*/
14-
public function __construct(public readonly ?PageOrientation $pageOrientation, public readonly array $extraOptions) {}
14+
public function __construct(
15+
public readonly ?PageOrientation $pageOrientation,
16+
public readonly array $extraOptions
17+
) {}
1518

1619
public static function create(): self
1720
{

src/Core/Bridge/FromHtmlFileToHtmlToPdf.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/Core/Bridge/FromHtmlToHtmlFileToPdf.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Core/Exception.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace KNPLabs\Snappy\Core;
6+
7+
abstract class Exception extends \Exception {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace KNPLabs\Snappy\Core\Exception;
6+
7+
use KNPLabs\Snappy\Core\Exception;
8+
9+
final class DOMDocumentException extends Exception {}

0 commit comments

Comments
 (0)