Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
88.89% covered (warning)
88.89%
8 / 9
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
FieldMDPTransformParams
88.89% covered (warning)
88.89%
8 / 9
50.00% covered (danger)
50.00%
1 / 2
4.02
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
85.71% covered (warning)
85.71%
6 / 7
0.00% covered (danger)
0.00%
0 / 1
3.03
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Interactive\Signature;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfName;
9use Phpdftk\Pdf\Core\PdfVersion;
10use Phpdftk\Pdf\Core\RequiresPdfVersion;
11
12/**
13 * FieldMDP transform parameters — ISO 32000-2 §12.8.2.4, Table 255.
14 *
15 * Locks specific form fields from further modification after signing.
16 *   /Action /All      — lock every field
17 *   /Action /Include  — lock the fields listed in /Fields
18 *   /Action /Exclude  — lock everything except the fields listed in /Fields
19 */
20#[RequiresPdfVersion(PdfVersion::V1_3)]
21class FieldMDPTransformParams extends TransformParams
22{
23    public PdfName $action;        // /Action
24    public ?PdfArray $fields = null; // /Fields  (required unless Action = /All)
25    public ?PdfName $v = null;     // /V
26
27    public function __construct(string $action = 'All', ?PdfArray $fields = null)
28    {
29        $this->action = new PdfName($action);
30        $this->fields = $fields;
31    }
32
33    public function toPdf(): string
34    {
35        $dict = $this->baseDictionary();
36        $dict->set('Action', $this->action);
37        if ($this->fields !== null) {
38            $dict->set('Fields', $this->fields);
39        }
40        if ($this->v !== null) {
41            $dict->set('V', $this->v);
42        }
43        return $dict->toPdf();
44    }
45}