Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| RenderResult | |
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
5.02 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasErrors | |
50.00% |
2 / 4 |
|
0.00% |
0 / 1 |
4.12 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\HtmlToPdf; |
| 6 | |
| 7 | use Phpdftk\Pdf\Writer\PdfWriter; |
| 8 | |
| 9 | /** |
| 10 | * Return value of {@see Renderer::render}: the populated `PdfWriter` plus |
| 11 | * the list of warnings emitted during rendering. `hasErrors()` reports |
| 12 | * whether any warning is `Error` severity (only possible in lenient mode; |
| 13 | * strict mode would have thrown instead). |
| 14 | */ |
| 15 | final readonly class RenderResult |
| 16 | { |
| 17 | /** @param list<Warning> $warnings */ |
| 18 | public function __construct( |
| 19 | public PdfWriter $writer, |
| 20 | public array $warnings, |
| 21 | ) {} |
| 22 | |
| 23 | public function hasErrors(): bool |
| 24 | { |
| 25 | foreach ($this->warnings as $w) { |
| 26 | if ($w->severity === WarningSeverity::Error) { |
| 27 | return true; |
| 28 | } |
| 29 | } |
| 30 | return false; |
| 31 | } |
| 32 | } |