Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
RedactAnnotation
100.00% covered (success)
100.00%
17 / 17
100.00% covered (success)
100.00%
2 / 2
9
100.00% covered (success)
100.00%
1 / 1
 getSubtype
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
1 / 1
8
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Annotation;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfBoolean;
9use Phpdftk\Pdf\Core\PdfNumber;
10use Phpdftk\Pdf\Core\PdfReference;
11use Phpdftk\Pdf\Core\PdfString;
12use Phpdftk\Pdf\Core\PdfVersion;
13use Phpdftk\Pdf\Core\RequiresPdfVersion;
14
15/**
16 * Redact annotation (/Subtype /Redact).
17 */
18#[RequiresPdfVersion(PdfVersion::V1_5)]
19class RedactAnnotation extends MarkupAnnotation
20{
21    public ?PdfArray $quadPoints = null;    // /QuadPoints
22    public ?PdfArray $ic = null;            // /IC - interior color
23    public ?PdfReference $ro = null;        // /RO - rollover appearance
24    public ?PdfString $overlayText = null;  // /OverlayText
25    public ?bool $repeat = null;            // /Repeat
26    public ?PdfString $da = null;           // /DA - default appearance
27    public ?int $q = null;                  // /Q - quadding (0=left, 1=center, 2=right)
28
29    public function getSubtype(): string
30    {
31        return 'Redact';
32    }
33
34    public function toPdf(): string
35    {
36        $dict = $this->buildDictionary();
37
38        if ($this->quadPoints !== null) {
39            $dict->set('QuadPoints', $this->quadPoints);
40        }
41        if ($this->ic !== null) {
42            $dict->set('IC', $this->ic);
43        }
44        if ($this->ro !== null) {
45            $dict->set('RO', $this->ro);
46        }
47        if ($this->overlayText !== null) {
48            $dict->set('OverlayText', $this->overlayText);
49        }
50        if ($this->repeat !== null) {
51            $dict->set('Repeat', new PdfBoolean($this->repeat));
52        }
53        if ($this->da !== null) {
54            $dict->set('DA', $this->da);
55        }
56        if ($this->q !== null) {
57            $dict->set('Q', new PdfNumber($this->q));
58        }
59
60        return $dict->toPdf();
61    }
62}