Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| NumberTree | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfObject; |
| 10 | use Phpdftk\Pdf\Core\PdfVersion; |
| 11 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 12 | |
| 13 | /** |
| 14 | * General-purpose integer-keyed tree node (ISO 32000-2 Table 37). |
| 15 | * |
| 16 | * Number trees map integer keys to arbitrary values. Leaf nodes contain |
| 17 | * /Nums arrays; intermediate nodes contain /Kids and /Limits. |
| 18 | */ |
| 19 | #[RequiresPdfVersion(PdfVersion::V1_2)] |
| 20 | class NumberTree extends PdfObject |
| 21 | { |
| 22 | public ?PdfArray $kids = null; // /Kids - intermediate node children |
| 23 | public ?PdfArray $nums = null; // /Nums - leaf node key-value pairs |
| 24 | public ?PdfArray $limits = null; // /Limits - [min max] for intermediate nodes |
| 25 | |
| 26 | public function toPdf(): string |
| 27 | { |
| 28 | $dict = new PdfDictionary(); |
| 29 | |
| 30 | if ($this->kids !== null) { |
| 31 | $dict->set('Kids', $this->kids); |
| 32 | } |
| 33 | if ($this->nums !== null) { |
| 34 | $dict->set('Nums', $this->nums); |
| 35 | } |
| 36 | if ($this->limits !== null) { |
| 37 | $dict->set('Limits', $this->limits); |
| 38 | } |
| 39 | |
| 40 | return $dict->toPdf(); |
| 41 | } |
| 42 | } |