Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
81.82% covered (warning)
81.82%
9 / 11
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
GoToEAction
81.82% covered (warning)
81.82%
9 / 11
66.67% covered (warning)
66.67%
2 / 3
6.22
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getActionType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
77.78% covered (warning)
77.78%
7 / 9
0.00% covered (danger)
0.00%
0 / 1
4.18
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Action;
6
7use Phpdftk\Pdf\Core\FileSpec\FileSpec;
8use Phpdftk\Pdf\Core\PdfBoolean;
9use Phpdftk\Pdf\Core\PdfDictionary;
10use Phpdftk\Pdf\Core\PdfReference;
11use Phpdftk\Pdf\Core\PdfVersion;
12use Phpdftk\Pdf\Core\RequiresPdfVersion;
13
14/**
15 * Go-to-embedded action (/S /GoToE) — ISO 32000-2 §12.6.4.4.
16 * Navigates to a destination inside an embedded PDF.
17 */
18#[RequiresPdfVersion(PdfVersion::V1_6)]
19class GoToEAction extends Action
20{
21    public FileSpec|PdfReference|null $f = null;   // /F  containing file
22    public mixed $d;                               // /D  destination (required)
23    public ?bool $newWindow = null;                // /NewWindow
24    public ?PdfDictionary $t = null;               // /T  target specifier
25
26    public function __construct(mixed $dest)
27    {
28        $this->d = $dest;
29    }
30
31    public function getActionType(): string
32    {
33        return 'GoToE';
34    }
35
36    public function toPdf(): string
37    {
38        $dict = $this->baseDictionary();
39        if ($this->f !== null) {
40            $dict->set('F', $this->f);
41        }
42        $dict->set('D', $this->d);
43        if ($this->newWindow !== null) {
44            $dict->set('NewWindow', new PdfBoolean($this->newWindow));
45        }
46        if ($this->t !== null) {
47            $dict->set('T', $this->t);
48        }
49        return $dict->toPdf();
50    }
51}