Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Thread
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 toPdf
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
3
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\PdfReference;
11use Phpdftk\Pdf\Core\PdfVersion;
12use Phpdftk\Pdf\Core\RequiresPdfVersion;
13
14/**
15 * Article thread dictionary (ISO 32000-2 Table 160).
16 *
17 * Represents an article thread, linking together a sequence of beads
18 * that form a logical reading order within the document.
19 */
20#[RequiresPdfVersion(PdfVersion::V1_1)]
21class Thread extends PdfObject
22{
23    public const PDF_TYPE = 'Thread';
24
25    public ?PdfDictionary $i = null;   // /I - thread info dict
26    public ?PdfReference $f = null;    // /F - first bead
27
28    public function toPdf(): string
29    {
30        $dict = new PdfDictionary();
31        $dict->set('Type', new PdfName(self::PDF_TYPE));
32
33        if ($this->i !== null) {
34            $dict->set('I', $this->i);
35        }
36        if ($this->f !== null) {
37            $dict->set('F', $this->f);
38        }
39
40        return $dict->toPdf();
41    }
42}