Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| RasterContentConstraint | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| check | |
100.00% |
10 / 10 |
|
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 | * ISO 23504-1 (PDF/R-1): Raster content validation. |
| 14 | * |
| 15 | * PDF/R-1 documents are intended for raster-only (scanned) content. |
| 16 | * This constraint warns if the document appears to contain non-raster |
| 17 | * content such as text or vector graphics (detected heuristically via |
| 18 | * font presence). |
| 19 | */ |
| 20 | final class RasterContentConstraint implements ConformanceConstraint |
| 21 | { |
| 22 | public function check(DocumentInspector $inspector, ConformanceProfile $profile): array |
| 23 | { |
| 24 | if ($inspector->hasRasterOnlyContent()) { |
| 25 | return []; |
| 26 | } |
| 27 | |
| 28 | return [ |
| 29 | new ConformanceViolation( |
| 30 | clause: '6.1', |
| 31 | message: 'PDF/R-1 documents should contain raster-only content; text or vector content detected', |
| 32 | severity: ViolationSeverity::Warning, |
| 33 | objectPath: 'Document', |
| 34 | ), |
| 35 | ]; |
| 36 | } |
| 37 | } |