Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
82.35% covered (warning)
82.35%
14 / 17
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ThreeDCrossSection
82.35% covered (warning)
82.35%
14 / 17
0.00% covered (danger)
0.00%
0 / 1
8.35
0.00% covered (danger)
0.00%
0 / 1
 toPdf
82.35% covered (warning)
82.35%
14 / 17
0.00% covered (danger)
0.00%
0 / 1
8.35
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\ThreeD;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfBoolean;
9use Phpdftk\Pdf\Core\PdfDictionary;
10use Phpdftk\Pdf\Core\PdfName;
11use Phpdftk\Pdf\Core\PdfObject;
12use Phpdftk\Pdf\Core\PdfVersion;
13use Phpdftk\Pdf\Core\RequiresPdfVersion;
14
15/**
16 * 3D cross-section dictionary (/Type /3DCrossSection) —
17 * ISO 32000-2 §13.6.8.
18 *
19 * Describes a clipping plane used to slice the 3D model.
20 */
21#[RequiresPdfVersion(PdfVersion::V1_6)]
22class ThreeDCrossSection extends PdfObject
23{
24    public const PDF_TYPE = '3DCrossSection';
25
26    public ?PdfArray $c = null;    // /C  center point
27    public ?PdfArray $o = null;    // /O  orientation
28    public ?PdfArray $pc = null;   // /PC plane color (3-element)
29    public ?float $pO = null;      // /PO plane opacity
30    public ?bool $iv = null;       // /IV show intersection
31    public ?PdfArray $ic = null;   // /IC intersection color
32    public ?bool $st = null;       // /ST show transparent
33
34    public function toPdf(): string
35    {
36        $dict = new PdfDictionary();
37        $dict->set('Type', new PdfName(self::PDF_TYPE));
38        if ($this->c !== null) {
39            $dict->set('C', $this->c);
40        }
41        if ($this->o !== null) {
42            $dict->set('O', $this->o);
43        }
44        if ($this->pc !== null) {
45            $dict->set('PC', $this->pc);
46        }
47        if ($this->pO !== null) {
48            $dict->set('PO', $this->pO);
49        }
50        if ($this->iv !== null) {
51            $dict->set('IV', new PdfBoolean($this->iv));
52        }
53        if ($this->ic !== null) {
54            $dict->set('IC', $this->ic);
55        }
56        if ($this->st !== null) {
57            $dict->set('ST', new PdfBoolean($this->st));
58        }
59        return $dict->toPdf();
60    }
61}