Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
SeedValueDictionary
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
14
100.00% covered (success)
100.00%
1 / 1
 toPdf
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
14
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Interactive\Form;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfBoolean;
9use Phpdftk\Pdf\Core\PdfDictionary;
10use Phpdftk\Pdf\Core\PdfName;
11use Phpdftk\Pdf\Core\PdfNumber;
12use Phpdftk\Pdf\Core\PdfObject;
13use Phpdftk\Pdf\Core\PdfString;
14use Phpdftk\Pdf\Core\PdfVersion;
15use Phpdftk\Pdf\Core\RequiresPdfVersion;
16
17/**
18 * Seed value dictionary — ISO 32000-2 §12.7.5.5, Table 234.
19 *
20 * Seeds constrain and configure how a signature field is signed:
21 * acceptable filter/subfilter, digest method, legal attestation,
22 * whether a timestamp is required, and whether the viewer is expected
23 * to lock the document after signing.
24 *
25 * Referenced from `SignatureField::$sv`.
26 */
27#[RequiresPdfVersion(PdfVersion::V1_3)]
28class SeedValueDictionary extends PdfObject
29{
30    public const PDF_TYPE = 'SV';
31
32    public ?int $ff = null;                      // /Ff  - flags
33    public ?PdfName $filter = null;              // /Filter
34    public ?PdfArray $subFilter = null;          // /SubFilter  array of names
35    public ?PdfArray $digestMethod = null;       // /DigestMethod  array of names
36    public ?float $v = null;                     // /V   seed dict version
37    public ?PdfDictionary $cert = null;          // /Cert certificate seed value dict
38    public ?PdfArray $reasons = null;            // /Reasons  array of strings
39    public ?PdfDictionary $mdp = null;           // /MDP
40    public ?PdfDictionary $timeStamp = null;     // /TimeStamp  time-stamp server dict
41    public ?PdfArray $legalAttestation = null;   // /LegalAttestation array of strings
42    public ?bool $addRevInfo = null;             // /AddRevInfo
43    #[RequiresPdfVersion(PdfVersion::V2_0)]
44    public ?bool $lockDocument = null;           // /LockDocument (PDF 2.0)
45    #[RequiresPdfVersion(PdfVersion::V2_0)]
46    public ?PdfString $appearanceFilter = null;  // /AppearanceFilter (PDF 2.0)
47
48    public function toPdf(): string
49    {
50        $dict = new PdfDictionary();
51        $dict->set('Type', new PdfName(self::PDF_TYPE));
52        if ($this->ff !== null) {
53            $dict->set('Ff', new PdfNumber($this->ff));
54        }
55        if ($this->filter !== null) {
56            $dict->set('Filter', $this->filter);
57        }
58        if ($this->subFilter !== null) {
59            $dict->set('SubFilter', $this->subFilter);
60        }
61        if ($this->digestMethod !== null) {
62            $dict->set('DigestMethod', $this->digestMethod);
63        }
64        if ($this->v !== null) {
65            $dict->set('V', new PdfNumber($this->v));
66        }
67        if ($this->cert !== null) {
68            $dict->set('Cert', $this->cert);
69        }
70        if ($this->reasons !== null) {
71            $dict->set('Reasons', $this->reasons);
72        }
73        if ($this->mdp !== null) {
74            $dict->set('MDP', $this->mdp);
75        }
76        if ($this->timeStamp !== null) {
77            $dict->set('TimeStamp', $this->timeStamp);
78        }
79        if ($this->legalAttestation !== null) {
80            $dict->set('LegalAttestation', $this->legalAttestation);
81        }
82        if ($this->addRevInfo !== null) {
83            $dict->set('AddRevInfo', new PdfBoolean($this->addRevInfo));
84        }
85        if ($this->lockDocument !== null) {
86            $dict->set('LockDocument', new PdfBoolean($this->lockDocument));
87        }
88        if ($this->appearanceFilter !== null) {
89            $dict->set('AppearanceFilter', $this->appearanceFilter);
90        }
91        return $dict->toPdf();
92    }
93}