Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ThreeDBackground | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\ThreeD; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\Graphics\ColorSpace\ColorSpace; |
| 8 | use Phpdftk\Pdf\Core\PdfArray; |
| 9 | use Phpdftk\Pdf\Core\PdfBoolean; |
| 10 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 11 | use Phpdftk\Pdf\Core\PdfName; |
| 12 | use Phpdftk\Pdf\Core\PdfObject; |
| 13 | use Phpdftk\Pdf\Core\PdfVersion; |
| 14 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 15 | |
| 16 | /** |
| 17 | * 3D background dictionary (/Type /3DBG) — ISO 32000-2 §13.6.5. |
| 18 | */ |
| 19 | #[RequiresPdfVersion(PdfVersion::V1_6)] |
| 20 | class ThreeDBackground extends PdfObject |
| 21 | { |
| 22 | public const PDF_TYPE = '3DBG'; |
| 23 | |
| 24 | public ColorSpace|PdfName|PdfArray|null $cs = null; // /CS colorspace |
| 25 | public ?PdfArray $c = null; // /C color |
| 26 | public ?bool $ea = null; // /EA apply also to crossing sections |
| 27 | |
| 28 | public function toPdf(): string |
| 29 | { |
| 30 | $dict = new PdfDictionary(); |
| 31 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 32 | if ($this->cs !== null) { |
| 33 | $dict->set('CS', $this->cs); |
| 34 | } |
| 35 | if ($this->c !== null) { |
| 36 | $dict->set('C', $this->c); |
| 37 | } |
| 38 | if ($this->ea !== null) { |
| 39 | $dict->set('EA', new PdfBoolean($this->ea)); |
| 40 | } |
| 41 | return $dict->toPdf(); |
| 42 | } |
| 43 | } |