Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Encoding | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Font; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfObject; |
| 11 | |
| 12 | /** |
| 13 | * Encoding object (/Type /Encoding). |
| 14 | * Defines the mapping of character codes to glyph names. |
| 15 | */ |
| 16 | class Encoding extends PdfObject |
| 17 | { |
| 18 | public const PDF_TYPE = 'Encoding'; |
| 19 | |
| 20 | public ?PdfName $baseEncoding = null; // /BaseEncoding |
| 21 | public ?PdfArray $differences = null; // /Differences |
| 22 | |
| 23 | public function toPdf(): string |
| 24 | { |
| 25 | $dict = new PdfDictionary(); |
| 26 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 27 | |
| 28 | if ($this->baseEncoding !== null) { |
| 29 | $dict->set('BaseEncoding', $this->baseEncoding); |
| 30 | } |
| 31 | if ($this->differences !== null) { |
| 32 | $dict->set('Differences', $this->differences); |
| 33 | } |
| 34 | |
| 35 | return $dict->toPdf(); |
| 36 | } |
| 37 | } |