Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PageContext | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Writer; |
| 6 | |
| 7 | /** |
| 8 | * Context passed to per-page render hooks (header / footer / watermark). |
| 9 | * |
| 10 | * Closures registered via {@see Pdf::setHeader()}, {@see Pdf::setFooter()}, |
| 11 | * or {@see Pdf::setWatermark()} receive this object so they can draw on |
| 12 | * the page with full knowledge of which page they're on, how many pages |
| 13 | * the final document will contain, and the page's geometry. |
| 14 | * |
| 15 | * Note: the closure runs in a deferred pass after all flow content has |
| 16 | * been placed, which is why `totalPages` is reliably set — unlike in |
| 17 | * the middle of `addText()` calls, where the document is still growing. |
| 18 | */ |
| 19 | final class PageContext |
| 20 | { |
| 21 | public function __construct( |
| 22 | public readonly int $pageNumber, |
| 23 | public readonly int $totalPages, |
| 24 | public readonly Page $page, |
| 25 | public readonly float $pageWidth, |
| 26 | public readonly float $pageHeight, |
| 27 | public readonly Theme $theme, |
| 28 | ) {} |
| 29 | } |