Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LineAnnotation
100.00% covered (success)
100.00%
25 / 25
100.00% covered (success)
100.00%
2 / 2
13
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%
24 / 24
100.00% covered (success)
100.00%
1 / 1
12
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\PdfName;
10use Phpdftk\Pdf\Core\PdfNumber;
11use Phpdftk\Pdf\Core\PdfReference;
12use Phpdftk\Pdf\Core\PdfVersion;
13use Phpdftk\Pdf\Core\RequiresPdfVersion;
14
15/**
16 * Line annotation (/Subtype /Line).
17 */
18#[RequiresPdfVersion(PdfVersion::V1_3)]
19class LineAnnotation extends MarkupAnnotation
20{
21    public ?PdfArray $l = null;        // /L - two points [x1 y1 x2 y2]
22    public ?PdfArray $le = null;       // /LE - line ending styles
23    public ?PdfArray $ic = null;       // /IC - interior color
24    public ?PdfNumber $ll = null;      // /LL - leader line length
25    public ?PdfNumber $lle = null;     // /LLE - leader line extension
26    public ?bool $cap = null;          // /Cap - caption flag
27    public ?PdfName $it = null;        // /IT - intent
28    public ?PdfNumber $llo = null;     // /LLO - leader line offset
29    public ?PdfName $cp = null;        // /CP - caption position
30    public ?PdfReference $measure = null; // /Measure
31    public ?PdfArray $co = null;       // /CO - caption offset
32
33    public function getSubtype(): string
34    {
35        return 'Line';
36    }
37
38    public function toPdf(): string
39    {
40        $dict = $this->buildDictionary();
41
42        if ($this->l !== null) {
43            $dict->set('L', $this->l);
44        }
45        if ($this->le !== null) {
46            $dict->set('LE', $this->le);
47        }
48        if ($this->ic !== null) {
49            $dict->set('IC', $this->ic);
50        }
51        if ($this->ll !== null) {
52            $dict->set('LL', $this->ll);
53        }
54        if ($this->lle !== null) {
55            $dict->set('LLE', $this->lle);
56        }
57        if ($this->cap !== null) {
58            $dict->set('Cap', new PdfBoolean($this->cap));
59        }
60        if ($this->it !== null) {
61            $dict->set('IT', $this->it);
62        }
63        if ($this->llo !== null) {
64            $dict->set('LLO', $this->llo);
65        }
66        if ($this->cp !== null) {
67            $dict->set('CP', $this->cp);
68        }
69        if ($this->measure !== null) {
70            $dict->set('Measure', $this->measure);
71        }
72        if ($this->co !== null) {
73            $dict->set('CO', $this->co);
74        }
75
76        return $dict->toPdf();
77    }
78}