Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
GoToDPAction
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 getActionType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Action;
6
7use Phpdftk\Pdf\Core\PdfDictionary;
8use Phpdftk\Pdf\Core\PdfReference;
9use Phpdftk\Pdf\Core\PdfVersion;
10use Phpdftk\Pdf\Core\RequiresPdfVersion;
11
12/**
13 * Go-to-document-part action (/S /GoToDP) — ISO 32000-2 §12.6.4.16.
14 * Jumps to a document part (PDF 2.0).
15 */
16#[RequiresPdfVersion(PdfVersion::V2_0)]
17class GoToDPAction extends Action
18{
19    public mixed $d = null;                       // /D  destination
20    public PdfDictionary|PdfReference|null $dp = null; // /DP document part
21
22    public function getActionType(): string
23    {
24        return 'GoToDP';
25    }
26
27    public function toPdf(): string
28    {
29        $dict = $this->baseDictionary();
30        if ($this->d !== null) {
31            $dict->set('D', $this->d);
32        }
33        if ($this->dp !== null) {
34            $dict->set('DP', $this->dp);
35        }
36        return $dict->toPdf();
37    }
38}