Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| DPartRootConstraint | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| check | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Conformance\Constraint; |
| 6 | |
| 7 | use Phpdftk\Pdf\Conformance\Inspection\DocumentInspector; |
| 8 | use Phpdftk\Pdf\Conformance\Profile\ConformanceProfile; |
| 9 | use Phpdftk\Pdf\Conformance\Result\ConformanceViolation; |
| 10 | use Phpdftk\Pdf\Conformance\Result\ViolationSeverity; |
| 11 | |
| 12 | /** |
| 13 | * PDF/VT: Catalog must have a /DPartRoot reference. |
| 14 | * |
| 15 | * The DPartRoot defines the document-part hierarchy used for |
| 16 | * variable-data printing workflows. This is the key structural |
| 17 | * requirement that distinguishes PDF/VT from plain PDF/X-4. |
| 18 | */ |
| 19 | final class DPartRootConstraint implements ConformanceConstraint |
| 20 | { |
| 21 | public function check(DocumentInspector $inspector, ConformanceProfile $profile): array |
| 22 | { |
| 23 | $catalog = $inspector->getCatalog(); |
| 24 | |
| 25 | if ($catalog->dPartRoot === null) { |
| 26 | return [new ConformanceViolation( |
| 27 | clause: '6.1', |
| 28 | message: 'Catalog /DPartRoot is required for ' . $profile->getFamily() . '-' . $profile->getLevel() . ' conformance', |
| 29 | severity: ViolationSeverity::Error, |
| 30 | objectPath: 'Catalog.DPartRoot', |
| 31 | )]; |
| 32 | } |
| 33 | |
| 34 | return []; |
| 35 | } |
| 36 | } |