Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| EmbeddedFileParams | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
6 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\FileSpec; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfNumber; |
| 9 | use Phpdftk\Pdf\Core\PdfString; |
| 10 | use Phpdftk\Pdf\Core\PdfVersion; |
| 11 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 12 | use Phpdftk\Pdf\Core\Serializable; |
| 13 | |
| 14 | /** |
| 15 | * Embedded file parameters (`/Params` entry of an EmbeddedFile stream) — |
| 16 | * ISO 32000-2 §7.11.4 Table 43. |
| 17 | * |
| 18 | * Appears inline inside an EmbeddedFile stream's dictionary; not a |
| 19 | * standalone indirect object. |
| 20 | */ |
| 21 | #[RequiresPdfVersion(PdfVersion::V1_3)] |
| 22 | class EmbeddedFileParams implements Serializable |
| 23 | { |
| 24 | public ?int $size = null; // /Size - file size |
| 25 | public ?PdfString $creationDate = null; // /CreationDate |
| 26 | public ?PdfString $modDate = null; // /ModDate |
| 27 | public ?PdfString $mac = null; // /Mac - legacy |
| 28 | public ?PdfString $checkSum = null; // /CheckSum (MD5, hex-encoded) |
| 29 | |
| 30 | public function toPdf(): string |
| 31 | { |
| 32 | $dict = new PdfDictionary(); |
| 33 | if ($this->size !== null) { |
| 34 | $dict->set('Size', new PdfNumber($this->size)); |
| 35 | } |
| 36 | if ($this->creationDate !== null) { |
| 37 | $dict->set('CreationDate', $this->creationDate); |
| 38 | } |
| 39 | if ($this->modDate !== null) { |
| 40 | $dict->set('ModDate', $this->modDate); |
| 41 | } |
| 42 | if ($this->mac !== null) { |
| 43 | $dict->set('Mac', $this->mac); |
| 44 | } |
| 45 | if ($this->checkSum !== null) { |
| 46 | $dict->set('CheckSum', $this->checkSum); |
| 47 | } |
| 48 | return $dict->toPdf(); |
| 49 | } |
| 50 | } |