Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
10 / 11
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
RenditionAction
90.91% covered (success)
90.91%
10 / 11
50.00% covered (danger)
50.00%
1 / 2
6.03
0.00% covered (danger)
0.00%
0 / 1
 getActionType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
90.00% covered (success)
90.00%
9 / 10
0.00% covered (danger)
0.00%
0 / 1
5.03
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Action;
6
7use Phpdftk\Pdf\Core\PdfNumber;
8use Phpdftk\Pdf\Core\PdfReference;
9use Phpdftk\Pdf\Core\PdfString;
10use Phpdftk\Pdf\Core\PdfVersion;
11use Phpdftk\Pdf\Core\RequiresPdfVersion;
12
13/**
14 * Rendition action (/S /Rendition) — ISO 32000-2 §13.2.2.
15 * Controls playback of media renditions.
16 */
17#[RequiresPdfVersion(PdfVersion::V1_5)]
18class RenditionAction extends Action
19{
20    public ?int $op = null;                  // /OP  operation (0..4)
21    public ?PdfReference $r = null;          // /R   rendition
22    public ?PdfReference $an = null;         // /AN  screen annotation
23    public ?PdfString $js = null;            // /JS  JavaScript
24
25    public function getActionType(): string
26    {
27        return 'Rendition';
28    }
29
30    public function toPdf(): string
31    {
32        $dict = $this->baseDictionary();
33        if ($this->op !== null) {
34            $dict->set('OP', new PdfNumber($this->op));
35        }
36        if ($this->r !== null) {
37            $dict->set('R', $this->r);
38        }
39        if ($this->an !== null) {
40            $dict->set('AN', $this->an);
41        }
42        if ($this->js !== null) {
43            $dict->set('JS', $this->js);
44        }
45        return $dict->toPdf();
46    }
47}