Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
81.82% covered (warning)
81.82%
9 / 11
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
TextAnnotation
81.82% covered (warning)
81.82%
9 / 11
50.00% covered (danger)
50.00%
1 / 2
6.22
0.00% covered (danger)
0.00%
0 / 1
 getSubtype
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
80.00% covered (warning)
80.00%
8 / 10
0.00% covered (danger)
0.00%
0 / 1
5.20
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Annotation;
6
7use Phpdftk\Pdf\Core\PdfBoolean;
8use Phpdftk\Pdf\Core\PdfName;
9use Phpdftk\Pdf\Core\PdfString;
10
11/**
12 * Text annotation (/Subtype /Text) - a "sticky note" annotation.
13 */
14class TextAnnotation extends MarkupAnnotation
15{
16    public ?bool $open = null;              // /Open
17    public ?PdfName $name = null;           // /Name (icon: Note, Comment, Key, etc.)
18    public ?PdfString $state = null;        // /State
19    public ?PdfString $stateModel = null;   // /StateModel
20
21    public function getSubtype(): string
22    {
23        return 'Text';
24    }
25
26    public function toPdf(): string
27    {
28        $dict = $this->buildDictionary();
29
30        if ($this->open !== null) {
31            $dict->set('Open', new PdfBoolean($this->open));
32        }
33        if ($this->name !== null) {
34            $dict->set('Name', $this->name);
35        }
36        if ($this->state !== null) {
37            $dict->set('State', $this->state);
38        }
39        if ($this->stateModel !== null) {
40            $dict->set('StateModel', $this->stateModel);
41        }
42
43        return $dict->toPdf();
44    }
45}