Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Info
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
1 / 1
10
100.00% covered (success)
100.00%
1 / 1
 toPdf
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
1 / 1
10
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Document;
6
7use Phpdftk\Pdf\Core\PdfDictionary;
8use Phpdftk\Pdf\Core\PdfName;
9use Phpdftk\Pdf\Core\PdfObject;
10use Phpdftk\Pdf\Core\PdfString;
11
12/**
13 * PDF Document Information Dictionary.
14 * Not a /Type object; embedded in the trailer's /Info entry.
15 */
16class Info extends PdfObject
17{
18    public ?PdfString $title = null;        // /Title
19    public ?PdfString $author = null;       // /Author
20    public ?PdfString $subject = null;      // /Subject
21    public ?PdfString $keywords = null;     // /Keywords
22    public ?PdfString $creator = null;      // /Creator
23    public ?PdfString $producer = null;     // /Producer
24    public ?PdfString $creationDate = null; // /CreationDate
25    public ?PdfString $modDate = null;      // /ModDate
26    public ?PdfName $trapped = null;        // /Trapped
27
28    public function toPdf(): string
29    {
30        $dict = new PdfDictionary();
31
32        if ($this->title !== null) {
33            $dict->set('Title', $this->title);
34        }
35        if ($this->author !== null) {
36            $dict->set('Author', $this->author);
37        }
38        if ($this->subject !== null) {
39            $dict->set('Subject', $this->subject);
40        }
41        if ($this->keywords !== null) {
42            $dict->set('Keywords', $this->keywords);
43        }
44        if ($this->creator !== null) {
45            $dict->set('Creator', $this->creator);
46        }
47        if ($this->producer !== null) {
48            $dict->set('Producer', $this->producer);
49        }
50        if ($this->creationDate !== null) {
51            $dict->set('CreationDate', $this->creationDate);
52        }
53        if ($this->modDate !== null) {
54            $dict->set('ModDate', $this->modDate);
55        }
56        if ($this->trapped !== null) {
57            $dict->set('Trapped', $this->trapped);
58        }
59
60        return $dict->toPdf();
61    }
62}