Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| MediaClipData | |
100.00% |
15 / 15 |
|
100.00% |
3 / 3 |
8 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMediaClipSubtype | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Multimedia; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\FileSpec\FileSpec; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfReference; |
| 11 | use Phpdftk\Pdf\Core\PdfString; |
| 12 | use Phpdftk\Pdf\Core\PdfVersion; |
| 13 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 14 | |
| 15 | /** |
| 16 | * Media clip data (/Type /MediaClip /S /MCD) — ISO 32000-2 §13.2.4.2. |
| 17 | * |
| 18 | * Points to the actual media bytes via a FileSpec (external or embedded) |
| 19 | * plus a MIME type. |
| 20 | */ |
| 21 | #[RequiresPdfVersion(PdfVersion::V1_5)] |
| 22 | class MediaClipData extends MediaClip |
| 23 | { |
| 24 | public FileSpec|PdfReference $d; // /D data (required) |
| 25 | public ?PdfString $ct = null; // /CT content type (MIME) |
| 26 | public ?PdfDictionary $p = null; // /P permissions dict |
| 27 | public ?PdfString $alt = null; // /Alt alternate texts |
| 28 | public ?PdfDictionary $pl = null; // /PL player list dict |
| 29 | public ?PdfDictionary $bu = null; // /BU base URL |
| 30 | |
| 31 | public function __construct(FileSpec|PdfReference $d) |
| 32 | { |
| 33 | $this->d = $d; |
| 34 | } |
| 35 | |
| 36 | public function getMediaClipSubtype(): string |
| 37 | { |
| 38 | return 'MCD'; |
| 39 | } |
| 40 | |
| 41 | public function toPdf(): string |
| 42 | { |
| 43 | $dict = $this->baseDictionary(); |
| 44 | $dict->set('D', $this->d); |
| 45 | if ($this->ct !== null) { |
| 46 | $dict->set('CT', $this->ct); |
| 47 | } |
| 48 | if ($this->p !== null) { |
| 49 | $dict->set('P', $this->p); |
| 50 | } |
| 51 | if ($this->alt !== null) { |
| 52 | $dict->set('Alt', $this->alt); |
| 53 | } |
| 54 | if ($this->pl !== null) { |
| 55 | $dict->set('PL', $this->pl); |
| 56 | } |
| 57 | if ($this->bu !== null) { |
| 58 | $dict->set('BU', $this->bu); |
| 59 | } |
| 60 | return $dict->toPdf(); |
| 61 | } |
| 62 | } |