Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
91.67% |
11 / 12 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Movie | |
91.67% |
11 / 12 |
|
50.00% |
1 / 2 |
6.02 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
5.02 | |||
| 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\PdfArray; |
| 9 | use Phpdftk\Pdf\Core\PdfBoolean; |
| 10 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 11 | use Phpdftk\Pdf\Core\PdfNumber; |
| 12 | use Phpdftk\Pdf\Core\PdfObject; |
| 13 | use Phpdftk\Pdf\Core\DeprecatedPdfFeature; |
| 14 | use Phpdftk\Pdf\Core\PdfReference; |
| 15 | use Phpdftk\Pdf\Core\PdfVersion; |
| 16 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 17 | |
| 18 | /** |
| 19 | * Movie dictionary — ISO 32000-2 §13.4 (deprecated in PDF 2.0 in favor |
| 20 | * of RichMedia, but still part of the spec and referenced by |
| 21 | * MovieAnnotation). |
| 22 | */ |
| 23 | #[RequiresPdfVersion(PdfVersion::V1_2)] |
| 24 | #[DeprecatedPdfFeature(since: '2.0', replacement: 'RichMediaAnnotation', removedIn: '2.0')] |
| 25 | class Movie extends PdfObject |
| 26 | { |
| 27 | public FileSpec|PdfReference $f; // /F file spec (required) |
| 28 | public ?PdfArray $aspect = null; // /Aspect [width height] |
| 29 | public ?float $rotate = null; // /Rotate degrees |
| 30 | public bool|PdfReference|null $poster = null; // /Poster |
| 31 | |
| 32 | public function __construct(FileSpec|PdfReference $f) |
| 33 | { |
| 34 | $this->f = $f; |
| 35 | } |
| 36 | |
| 37 | public function toPdf(): string |
| 38 | { |
| 39 | $dict = new PdfDictionary(); |
| 40 | $dict->set('F', $this->f); |
| 41 | if ($this->aspect !== null) { |
| 42 | $dict->set('Aspect', $this->aspect); |
| 43 | } |
| 44 | if ($this->rotate !== null) { |
| 45 | $dict->set('Rotate', new PdfNumber($this->rotate)); |
| 46 | } |
| 47 | if ($this->poster !== null) { |
| 48 | if (is_bool($this->poster)) { |
| 49 | $dict->set('Poster', new PdfBoolean($this->poster)); |
| 50 | } else { |
| 51 | $dict->set('Poster', $this->poster); |
| 52 | } |
| 53 | } |
| 54 | return $dict->toPdf(); |
| 55 | } |
| 56 | } |