Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LaunchAction
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
7
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%
12 / 12
100.00% covered (success)
100.00%
1 / 1
6
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 * Launch action (/S /Launch) — ISO 32000-2 §12.6.4.5.
16 * Launches an application or opens/prints a document.
17 */
18#[RequiresPdfVersion(PdfVersion::V1_1)]
19class LaunchAction extends Action
20{
21    public FileSpec|PdfReference|null $f = null;   // /F
22    public ?PdfDictionary $win = null;             // /Win
23    public ?PdfDictionary $mac = null;             // /Mac
24    public ?PdfDictionary $unix = null;            // /Unix
25    public ?bool $newWindow = null;                // /NewWindow
26
27    public function getActionType(): string
28    {
29        return 'Launch';
30    }
31
32    public function toPdf(): string
33    {
34        $dict = $this->baseDictionary();
35        if ($this->f !== null) {
36            $dict->set('F', $this->f);
37        }
38        if ($this->win !== null) {
39            $dict->set('Win', $this->win);
40        }
41        if ($this->mac !== null) {
42            $dict->set('Mac', $this->mac);
43        }
44        if ($this->unix !== null) {
45            $dict->set('Unix', $this->unix);
46        }
47        if ($this->newWindow !== null) {
48            $dict->set('NewWindow', new PdfBoolean($this->newWindow));
49        }
50        return $dict->toPdf();
51    }
52}