Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Requirement | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfObject; |
| 11 | use Phpdftk\Pdf\Core\PdfVersion; |
| 12 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 13 | |
| 14 | /** |
| 15 | * Requirement dictionary — ISO 32000-2 §12.10, Table 253. |
| 16 | * |
| 17 | * Declares processor capabilities that a conforming reader must support |
| 18 | * to fully render the document. Referenced from `Catalog::$requirements`. |
| 19 | */ |
| 20 | #[RequiresPdfVersion(PdfVersion::V1_7)] |
| 21 | class Requirement extends PdfObject |
| 22 | { |
| 23 | public const PDF_TYPE = 'Requirement'; |
| 24 | |
| 25 | public PdfName $s; // /S - subtype (EnableJavaScripts, …) |
| 26 | public ?PdfArray $rh = null; // /RH - requirement handlers |
| 27 | |
| 28 | public function __construct(string $subtype) |
| 29 | { |
| 30 | $this->s = new PdfName($subtype); |
| 31 | } |
| 32 | |
| 33 | public function toPdf(): string |
| 34 | { |
| 35 | $dict = new PdfDictionary(); |
| 36 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 37 | $dict->set('S', $this->s); |
| 38 | if ($this->rh !== null) { |
| 39 | $dict->set('RH', $this->rh); |
| 40 | } |
| 41 | return $dict->toPdf(); |
| 42 | } |
| 43 | } |